def add_tree(self, tree, parent=None):
        """
        Add `tree` into database.

        Args:
            tree (obj): :class:`.Tree` instance.
            parent (ref, default None): Reference to parent tree. This is used
                for all sub-trees in recursive call.
        """
        if tree.path in self.path_db:
            self.remove_tree_by_path(tree.path)

        # index all indexable attributes
        for index in tree.indexes:
            if not getattr(tree, index):
                continue

            self._add_to(
                getattr(self, index + "_db"),
                getattr(tree, index),
                tree,
            )

        if parent:
            self._add_to(self.parent_db, tree.path, parent)

        # make sure, that all sub-trees starts with path of parent tree
        for sub_tree in tree.sub_trees:
            assert sub_tree.path.startswith(tree.path)

        for sub_tree in tree.sub_trees:
            self.add_tree(sub_tree, parent=tree)
def add_tree ( self , tree , parent = None ) : if tree . path in self . path_db : self . remove_tree_by_path ( tree . path ) for index in tree . indexes : if not getattr ( tree , index ) : continue self . _add_to ( getattr ( self , index + "_db" ) , getattr ( tree , index ) , tree , ) if parent : self . _add_to ( self . parent_db , tree . path , parent ) for sub_tree in tree . sub_trees : assert sub_tree . path . startswith ( tree . path ) for sub_tree in tree . sub_trees : self . add_tree ( sub_tree , parent = tree )
Add `tree` into database.

        Args:
            tree (obj): :class:`.Tree` instance.
            parent (ref, default None): Reference to parent tree. This is used
                for all sub-trees in recursive call.