This function check that the category parent exist and has not others tags for the same language.
768458
def check_lato_blog_tag_parent
      tag_parent = LatoBlog::TagParent.find_by(id: lato_blog_tag_parent_id)
      if !tag_parent
        errors.add('Tag parent', 'not exist for the tag')
        throw :abort
        return
      end

      same_language_tag = tag_parent.tags.find_by(meta_language: meta_language)
      if same_language_tag && same_language_tag.id != id
        errors.add('Tag parent', 'has another tag for the same language')
        throw :abort
        return
      end
    end
1146202
function checkIfStyleCanBeChildOf( def, currentParent, elementName, isUnknownElement ) {
		return currentParent &&
			( ( currentParent.getDtd() || CKEDITOR.dtd.span )[ elementName ] || isUnknownElement ) &&
			( !def.parentRule || def.parentRule( currentParent ) );
	}
462866
public function load_parent_category() {
        if (empty($this->parent_category->id)) {
            $this->parent_category = $this->get_parent_category();
        }
        return $this->parent_category;
    }
241320
public boolean contains(final String category, final String checkId) {
		return (rules.containsKey(getRuleKey(category, checkId)));
	}
764418
function contains(parent, child) {
		if (!parent || !child) { return false; }
		if (parent === child) { return true; }
		var compare = parent.compareDocumentPosition(child);  // useful to break out for debugging
		return Boolean(compare & 16);
	}
30071
protected function _checkParents()
	{
		//pierwszy rodzic
		$parent = $this->_category->getParentRecord();
		//gdy jest rodzic
		while ($parent !== null) {
			//jeśli nie ma dostępu do tego rodzica
			if (!$this->_checkAccess($parent->id)) {
				return false;
			}
			//pobieramy kolejnego rodzica
			$parent = $parent->getParentRecord();
		}
		return true;
	}
678829
function hasParentRule(rule) {
  if (!rule.parent) {
    return false
  }

  if (rule.parent.type === 'rule') {
    return true
  }

  return hasParentRule(rule.parent)
}
410199
def find_category(self, parent_alias, title):
        
        found = None
        child_ids = self.get_child_ids(parent_alias)
        for cid in child_ids:
            category = self.get_category_by_id(cid)
            if category.title.lower() == title.lower():
                found = category
                break
        return found
273341
def blog__clean_category_parents
      category_parents = LatoBlog::CategoryParent.all
      category_parents.map { |cp| cp.destroy if cp.categories.empty? }
    end
1032089
function sameParentChecker (preprocessFn) {
    return function (suggestions) {
        if (suggestions.length === 0) {
            return false;
        }
        if (suggestions.length === 1) {
            return true;
        }

        var parentValue = preprocessFn(suggestions[0].value),
            aliens = suggestions.filter(function (suggestion) {
                return preprocessFn(suggestion.value).indexOf(parentValue) !== 0;
            });

        return aliens.length === 0;
    }
}
950835
private function findCategoriesWithoutParents()
    {
        // get categories that have no parent but depth > 0
        $qb = $this->categoryRepository->createQueryBuilder('c2')
            ->select('count(c2.id)')
            ->leftJoin('c2.parent', 'c1')
            ->where('c2.depth <> 0 AND c2.parent IS NULL');

        return $qb->getQuery()->getSingleScalarResult();
    }
769830
function isChild(child, parent) {
	while (child = child.parentNode) {
		if (child == parent) {
			return true;
		}
	}

	return false;
}
1063306
private boolean checkParents(boolean exclusive) {
        if (_path.equals("/")) {
            return true;
        } else {
            if (_owner == null) {
                // no owner, checking parents
                return _parent != null && _parent.checkParents(exclusive);
            } else {
                // there already is a owner
                return !(_exclusive || exclusive)
                        && _parent.checkParents(exclusive);
            }
        }
    }
474995
def parent(self, parent_object, limit_parent_language=True):
        
        return self.all().parent(parent_object, limit_parent_language)
834221
private boolean checkParents( boolean exclusive ) {
        if (path.equals("/")) {
            return true;
        }
        if (owner == null) {
            // no owner, checking parents
            return parent != null && parent.checkParents(exclusive);
        }
        // there already is a owner
        return !(this.exclusive || exclusive) && parent.checkParents(exclusive);
    }
860020
def count_of_certain_category(cat_id, tag=''):
        '''
        
        '''

        if cat_id.endswith('00'):
            # The first level category, using the code bellow.
            cat_con = TabPost2Tag.par_id == cat_id
        else:
            cat_con = TabPost2Tag.tag_id == cat_id

        if tag:
            condition = {
                'def_tag_arr': [tag]
            }
            recs = TabPost2Tag.select().join(
                TabPost,
                on=((TabPost2Tag.post_id == TabPost.uid) & (TabPost.valid == 1))
            ).where(
                cat_con & TabPost.extinfo.contains(condition)
            )
        else:
            recs = TabPost2Tag.select().where(
                cat_con
            )

        return recs.count()
689803
def category(self) -> Optional[str]:
        ''''''
        if self.statements:
            if self.statements[-1][0] == ':':
                # a hack. ... to avoid calling isValid recursively
                def validDirective():
                    if not self.values:
                        return True
                    if self.values[-1].strip().endswith(','):
                        return False
                    try:
                        compile(
                            'func(' + ''.join(self.values) + ')',
                            filename='<string>',
                            mode='eval')
                    except Exception:
                        return False
                    return True

                if validDirective() and self._action is not None:
                    return 'script'
                return 'directive'
            return 'statements'
        return None