This function check the category parent of the category do not create a circular dependency.
342952
def check_category_father_circular_dependency
      return unless self.lato_blog_category_id

      all_children = self.get_all_category_children
      same_children = all_children.select { |child| child.id === self.lato_blog_category_id }

      if same_children.length > 0
        errors.add('Category father', 'can not be a children of the category')
        throw :abort
      end
    end
1097206
def _assert_category(self, category):
        """"""
        category = category.lower()
        valid_categories = ['cable', 'broadcast', 'final', 'tv']
        assert_msg = "%s is not a valid category." % (category)
        assert (category in valid_categories), assert_msg
208031
def is_parent_of(self, parent, child):
        
        if parent == 'trunk':
            return True
        if child == 'trunk':
            return False
        if child not in self._branches:
            raise ValueError(
                "The branch {} seems not to have ever been created".format(
                    child
                )
            )
        if self._branches[child][0] == parent:
            return True
        return self.is_parent_of(parent, self._branches[child][0])
1111272
public boolean parent() {
        if (mNode == null) {
            return false;
        }
        AccessibilityNodeInfoCompat parentNode = mNode.getParent();
        while (parentNode != null) {
            if (AccessibilityNodeInfoUtils.isVisibleOrLegacy(parentNode)) {
                reset(parentNode);
                return true;
            }
            AccessibilityNodeInfoCompat tmp = parentNode.getParent();
            parentNode.recycle();
            parentNode = tmp;
        }
        return false;
    }
241320
public boolean contains(final String category, final String checkId) {
		return (rules.containsKey(getRuleKey(category, checkId)));
	}
971160
public void checkParentLinks() {
        this.visit(new NodeVisitor() {
            @Override
            public boolean visit(AstNode node) {
                int type = node.getType();
                if (type == Token.SCRIPT)
                    return true;
                if (node.getParent() == null)
                    throw new IllegalStateException
                            ("No parent for node: " + node
                             + "\n" + node.toSource(0));
                return true;
            }
        });
    }
1062735
public function get_parent_category() {
        if ($this->is_category_item() or $this->is_course_item()) {
            return $this->get_item_category();

        } else {
            return grade_category::fetch(array('id'=>$this->categoryid));
        }
    }
1219781
def parent(self):
        '''
        
        '''
        if check_path(self.path, self.app.config['directory_base']):
            return None
        parent = os.path.dirname(self.path) if self.path else None
        return self.directory_class(parent, self.app) if parent else None
51573
public function get_parent_category() {
        if (!empty($this->parent)) {
            $parent_category = new grade_category(array('id' => $this->parent));
            return $parent_category;
        } else {
            return null;
        }
    }
1142676
def _is_parent(self, roleid1, roleid2):
        """"""

        role2 = copy.deepcopy(self.flatten[roleid2])
        role1 = copy.deepcopy(self.flatten[roleid1])

        if role1 == role2:
            return False

        # Check if role1 is contained by role2
        for b1 in role1['backends_groups']:
            if b1 not in role2['backends_groups']:
                return False
            for group in role1['backends_groups'][b1]:
                if group not in role2['backends_groups'][b1]:
                    return False

        # If role2 is inside role1, roles are equal, throw exception
        for b2 in role2['backends_groups']:
            if b2 not in role1['backends_groups']:
                return True
            for group in role2['backends_groups'][b2]:
                if group not in role1['backends_groups'][b2]:
                    return True
        raise DumplicateRoleContent(roleid1, roleid2)
219871
private boolean isParentLoader(ClassLoader parent, ClassLoader child)
  {
    for (; child != null; child = child.getParent()) {
      if (child == parent)
        return true;
    }

    return false;
  }
388051
function (parentType, childType) {
        if (!jv._options.checkInheritance) {
            return true;
        }
        var typeRef = childType;
        while (!typeRef[jv._MD_BUILTIN]) {
            if (parentType == typeRef) {
                return true;
            }
            typeRef = typeRef[jv._MD_PARENTDEF];
        }
        jv._logError(jv.INHERITANCE_EXPECTED, [childType[jv._MD_TYPENAME], parentType[jv._MD_TYPENAME]]);
        return false;
    }
901616
def has_parent(self, term):
        """"""
        for parent in self.parents:
            if parent.item_id == term or parent.has_parent(term):
                return True
        return False
827774
public static boolean parentContainsOnlyLeaves(ParentNode parentNode) {
        for (Node child : parentNode.children()) {
            if (!isLeaf(child)) return false;
        }
        return true;
    }
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
658853
public function addParentCategory(CategoryInterface $category): CategoryInterface
    {
        if (!$this->hasParentCategory($category)) {
            $this->parentCategories->add($category);
        }

        return $this;
    }
163367
protected function initParentCategory()
    {
        if (!array_key_exists('parent_id', $this->arImportData)) {
            return;
        }

        $iParentID = array_get($this->arImportData, 'parent_id');
        array_forget($this->arImportData, 'parent_id');
        if (empty($iParentID)) {
            $this->obParentCategory = false;

            return;
        }

        //Find parent category
        $this->obParentCategory = Category::getByExternalID($iParentID)->first();
    }