Return a the minimum tree to display for a node

@return array The tree

@api
350731
public function getReducedTree()
    {
        $parseTree = function (Node $node, Node $target) use ( &$parseTree ) {
            if (substr($target->getPath(),0, strlen($node->getPath())) != $node->getPath()) {
                return array();
            }
            $tree = array();

            foreach ($node->getNodes() as $child) {
                $tree[] = array(
                    'name'          =>  $child->getName(),
                    'path'          =>  $child->getPath(),
                    'hasChildren'   =>  $child->hasNodes(),
                    'children'      =>  $parseTree($child, $target)
                );
            }

            return $tree;
        };

        $treeFactory = function($parent, $node) use ($parseTree) {
            return [ '/' => [
                'name'          =>  '/',
                'path'          =>  '/',
                'hasChildren'   =>  $parent->hasNodes(),
                'children'      =>  $parseTree($parent, $node)
            ]];
        };

        if ($this->getPath() == '/') {
            return $treeFactory($this, $this);
        }

        $parent = $this;
        do {
            $parent = $parent->getParent();
        } while ($parent->getPath() != '/');

        return $treeFactory($parent, $this);
    }
986926
public function getChildren()
    {
        $nodes = [];
        try {
            $child = $this->firstChild();
            do {
                $nodes[] = $child;
                $child   = $this->nextChild($child->id());
            } while ( ! is_null($child));
        } catch (ChildNotFoundException $e) {
            // we are done looking for children
        }

        return $nodes;
    }
506442
public function getPathTree(): array
    {
        $tree = [];
        foreach ($this->getTree() as $branch) {
            $tree[] = Path::make($branch);
        }

        return $tree;
    }
1074856
protected function getCurrentNodeRootline()
    {
        if ($this->currentNodeRootline === null) {
            $nodeRootline = $this->currentNode->getContext()->getNodesOnPath($this->currentNode->getContext()->getCurrentSiteNode()->getPath(), $this->currentNode->getPath());
            $this->currentNodeRootline = [];

            foreach ($nodeRootline as $rootlineElement) {
                $this->currentNodeRootline[$this->getNodeLevelInSite($rootlineElement)] = $rootlineElement;
            }
        }

        return $this->currentNodeRootline;
    }
1311197
public function getConfigTree()
    {
        $treeBuilder = new TreeBuilder();
        $treeBuilder->root('sixdays_opcache', 'array')
            ->isRequired()
            ->children()
                ->scalarNode('base_url')->isRequired()->end()
                ->scalarNode('web_dir')->isRequired()->end()
            ->end()
        ->end();

        return $treeBuilder->buildTree();
    }
895091
public function tree()
    {
        $items = $this->model
            ->orderBy('id')
            ->orderBy('parent_id')
            ->with($this->with)
            ->get(['id', 'title', 'parent_id'])
            ->toArray();

        return $this->toTree($items);
    }
736745
public function actionTree()
    {
        $tree = DpAdminMenu::getAccessTreeByParentId($this->identity->is_super, $this->menuIdList, null, [
            'is_hide' => 0,
        ]);

        return [
            'children' => $tree,
        ];
    }
1025032
public function getRoot()
    {
        $tmp_parent = $this->getParent();
        $root = $tmp_parent;
        while ($tmp_parent) {
            $root = $tmp_parent;
            $tmp_parent = $tmp_parent->getParent();
        }

        return $root;
    }
519265
private function get_default_tree_structure() {

        $frontpage = \context_course::instance(SITEID);

        $categorybranches = $this->get_all_category_branches();

        $elements = [
            'text' => get_string('contextlevelname' . CONTEXT_SYSTEM, 'tool_dataprivacy'),
            'contextlevel' => CONTEXT_SYSTEM,
            'branches' => [
                [
                    'text' => get_string('user'),
                    'contextlevel' => CONTEXT_USER,
                ], [
                    'text' => get_string('categories'),
                    'branches' => $categorybranches,
                    'expandelement' => 'category',
                ], [
                    'text' => get_string('frontpagecourse', 'tool_dataprivacy'),
                    'contextid' => $frontpage->id,
                    'branches' => [
                        [
                            'text' => get_string('activitiesandresources', 'tool_dataprivacy'),
                            'expandcontextid' => $frontpage->id,
                            'expandelement' => 'module',
                            'expanded' => 0,
                        ], [
                            'text' => get_string('blocks'),
                            'expandcontextid' => $frontpage->id,
                            'expandelement' => 'block',
                            'expanded' => 0,
                        ],
                    ]
                ]
            ]
        ];

        // Returned as an array to follow a common array format.
        return [self::complete($elements, $this->defaultcontextlevel, $this->defaultcontextid)];
    }
505724
public function getNodeBuilder()
    {
        if (!isset($this->nodeBuilder)) {
            $this->nodeBuilder = $this->getGeneratorConfig()->getConfiguredBuilder($this->getTable(), 'node');
        }

        return $this->nodeBuilder;
    }
115407
protected function getNodeBuilder()
    {
        if (null === $this->nodeBuilder) {
            $this->nodeBuilder = new NodeBuilder();
        }

        return $this->nodeBuilder->setParent($this);
    }
168872
public function getChildren()
    {
        $children = [];
        $notifications = $this->caldavBackend->getNotificationsForPrincipal($this->principalUri);

        foreach ($notifications as $notification) {
            $children[] = new Node(
                $this->caldavBackend,
                $this->principalUri,
                $notification
            );
        }

        return $children;
    }
13980
public function getSubTreeLimitations()
    {
        if ( $this->attribute( 'main_tag_id' ) != 0 )
            return array();

        return parent::fetchObjectList( eZContentClassAttribute::definition(), null,
                                                    array( 'data_type_string'              => 'eztags',
                                                           eZTagsType::SUBTREE_LIMIT_FIELD => $this->attribute( 'id' ),
                                                           'version'                       => eZContentClass::VERSION_STATUS_DEFINED ) );
    }
1203118
public function getConfigTreeBuilder()
    {
        $node = $this->getRootNode();
        $node = $node->children();
        $node = $this->getChildren($node);
        $node = $node->end();

        return $node;
    }
380774
public function getAutoCreatedChildNodes()
    {
        $this->initialize();
        if (!isset($this->fullConfiguration['childNodes'])) {
            return [];
        }

        $autoCreatedChildNodes = [];
        foreach ($this->fullConfiguration['childNodes'] as $childNodeName => $childNodeConfiguration) {
            if (isset($childNodeConfiguration['type'])) {
                $autoCreatedChildNodes[Utility::renderValidNodeName($childNodeName)] = $this->nodeTypeManager->getNodeType($childNodeConfiguration['type']);
            }
        }

        return $autoCreatedChildNodes;
    }
108228
public function getCategoriesTree()
    {
        $allCategories = $this->getCategories();
        $topCategories = [];

        $currentCategory = null;

        // Building tree from categories collection
        foreach ($allCategories as $idCat => $category) {

            // If level, we put category in an array with only top level categories.
            $topLevel = 2; // 1 is root category
            if ($category->getLevel() == $topLevel && !isset($topCategories[$idCat])) {
                $topCategories[$idCat] = $category;
            } else {
                // Foreach categories with sub category we add a child to the parent
                if (!isset($allCategories[$category->getParentId()])) {
                    // Ignore if no parent
                    continue;
                }
                $parent           = $allCategories[$category->getParentId()];
                $children         = $parent->getData('_children') ?: [];
                $children[$idCat] = $category;
                $category->setData('_parent', $parent);
                $parent->setData('_children', $children);
            }

            if ((int) $idCat === $this->getCurrentCategoryId()) {
                $currentCategory = $category;
            }
        }

        // Set current path
        if (null !== $currentCategory) {
            $setCategoryAsCurrent = function (Mage_Catalog_Model_Category $category, $isParent = false) use (&$setCategoryAsCurrent) {
                if ($isParent) {
                    $category->setContainsCurrentCategory(true);
                } else {
                    $category->setIsCurrentCategory(true);
                }
                if ($parentCategory = $category->getData('_parent')) {
                    $setCategoryAsCurrent($parentCategory, true);
                }
            };
            $setCategoryAsCurrent($currentCategory);
        }

        return $topCategories;
    }
393063
public function rootNodes()
    {
        $query = $this->model->newQuery()->whereNull($this->parentIdKey);

        $this->callBeforeListeners('rootNodes', [$query]);

        $nodes = $query->get()->all();

        $this->callAfterListeners('rootNodes', [$nodes]);

        return $nodes;
    }