Get Nodes to display

@param array $nodes

@return array
503359
protected function getGrantedNodes(array $nodes)
    {
        /**
         * @var ReadNodeInterface $node
         */
        foreach ($nodes as $key => $node) {
            if (!$this->isGrantedNode($node)) {
                unset($nodes[$key]);
            }
        }

        return $nodes;
    }
861112
public static function sortNodes($nodes)
    {
        // saves node paths
        foreach ($nodes as $node) {
            if (!isset($node->__path__)) {
                $node->__path__ = Dom::_getNodePath($node);
            }
        }

        // sorts elements in the same order they appear in the document
        usort(
            $nodes,
            function ($node0, $node1) {
                $path0 = $node0->__path__;
                $path1 = $node1->__path__;
                $count0 = count($path0);
                $count1 = count($path1);
                $len = min($count0, $count1);

                for ($i = 0; $i < $len; $i++) {
                    if ($path0[$i] != $path1[$i]) {
                        return $path0[$i] > $path1[$i];
                    }
                }

                return $count0 > $count1;
            }
        );
        
        // unsets __path__
        foreach ($nodes as $node) {
            unset($node->__path__);
        }
        
        return $nodes;
    }
1032829
private function resolveImportTable(Node $node): array
    {
        try {
            return $node->getImportTablesForCurrentScope();
        } catch (Exception $e) {
        }

        foreach ($node->getDescendantNodes() as $node) {
            try {
                $imports = $node->getImportTablesForCurrentScope();
                if (empty($imports[0])) {
                    continue;
                }
                return $imports;
            } catch (Exception $e) {
            }
        }

        return [ [], [], [] ];
    }
676688
private function getNodeIndex( $node )
	{
		for( $i=0; $i<$this->count(); $i++ )
			if( $this->nodes[$i] == $node )
				return $i;
		return NULL;
	}
729993
private function collectNodes(NodeInterface $node, array $visited_nodes): array
    {
        if (in_array($node, $visited_nodes, true)) {
            return $visited_nodes;
        }

        $visited_nodes[] = $node;
        foreach ($node->getChildren() as $child) {
            $visited_nodes = $this->collectNodes($child, $visited_nodes);
        }

        return $visited_nodes;
    }
960349
protected function convertNodes(Array $nodes, $em) {
    // our test project (this) is defined to have only de as i18n but dont get confused, these are english wordings
    $navigationNodes = array();

    foreach ($nodes as $node) {
      $node = (object) $node;
      $navigationNode = $this->createNode(array('de'=>$node->title));
      $navigationNode->setContext($this->context);
      $navigationNode->generateSlugs();

      $page = $this->createPage($navigationNode->getSlug('de'));
      $page->setActive(TRUE);
      $em->persist($page);

      $navigationNode->setPage($page);

      $navigationNodes[$navigationNode->getTitle('de')] = $navigationNode;
    }

    foreach ($nodes as $node) {
      $node = (object) $node;

      if (isset($node->parent)) {
        $navigationNodes[$node->title]->setParent($navigationNodes[$node->parent]);
      }
    }

    return $navigationNodes;
  }
1017940
protected function nodeToDictionary( Node $node )
    {
        $result = $node->attributes;

        $containerKeys = [];

        foreach ($node->children as $child) {
            $arrayChild = $this->nodeToDictionary($child);

            $childName = $child->name;
            $childValue = $arrayChild;

            if (sizeof($child->children) == 0) {
                $childValue = $child->text;
            }

            if (isset( $result[ $childName ] )) {
                if (!in_array($childName, $containerKeys)) {
                    $result[ $childName ] = [$result[ $childName ]];
                    $containerKeys[] = $childName;
                }

                $result[ $childName ][] = $childValue;
            } else {
                $result[ $childName ] = $childValue;
            }
        }

        return $result;
    }
164017
protected function getItems(array $items)
	{
		$result = array();
		foreach($items as $item) {
			$result[] = $this->getItem($item);
		}
		return $result;
	}
447512
public function filterNodeDepth($nodes, $depth)
    {
        if(empty($nodes) || $depth === 0)
        {
            return array();
        }

        $newNodes = array();
        $stack = array();
        $level = 0;

        foreach($nodes as $node)
        {
            $parent = end($stack);
            while($parent && $node->getLeftValue() > $parent->getRightValue())
            {
                array_pop($stack);
                $parent = end($stack);
                $level--;
            }

            if($level < $depth)
            {
                $newNodes[] = $node;
            }

            if(($node->getRightValue() - $node->getLeftValue()) > 1)
            {
                array_push($stack, $node);
                $level++;
            }
        }

        return $newNodes;
    }
953366
public function getNodes()
    {
        if (is_null($this->_nodes)) {
            $this->_nodes = new FileSystemList(
                $this->details->getRealPath()
            );
        }
        return $this->_nodes;
    }
538895
public function getTextFromArray(array $keys = [])
    {
        $values = [];
        foreach ($keys as $key) {
            $values[$key] = $this->getText($key);
        }
        return $values;
    }
53130
public static function findClassLikeNodes(array $nodes): array
    {
        $collectedNodes = [];

        foreach ($nodes as $node) {
            if ($node instanceof Node\Stmt\ClassLike) {
                $collectedNodes[] = $node;
            } elseif ($node instanceof Use_) {
                continue;
            } elseif (is_array($node)) {
                $collectedNodes = array_merge(
                    static::findClassLikeNodes($node),
                    $collectedNodes
                );
            } elseif ($node instanceof Node) {
                $collectedNodes = array_merge(
                    static::findClassLikeNodes(static::getSubNodes($node)),
                    $collectedNodes
                );
            }
        }

        return $collectedNodes;
    }
1041254
public function setNodes(ArrayCollection $nodes)
    {
        $finalNodes = array();

        foreach ($nodes as $node) {
            if ($this->checkChildNode($node)) {
                $node->setParent($this);
                $finalNodes[] = $node;
            }
        }

        $this->nodes = $finalNodes;

        return $this;
    }
463669
protected function getItemsAsArray($items)
    {
        if (is_array($items)) {
            return $items;
        } elseif ($items instanceof self) {
            return $items->all();
        } elseif ($items instanceof Traversable) {
            return iterator_to_array($items);
        }

        return (array) $items;
    }
970958
public static function getRootPageIdsFromSites(array $sites): array
    {
        $rootPageIds = [];
        foreach ($sites as $site) {
            $rootPageIds[] = (int)$site->getRootPageId();
        }

        return $rootPageIds;
    }
549912
protected function fillTreeNodesForItems($tree, $nodes)
    {
        foreach ($tree as $key => $item) {
            $tree[$key]['node'] = $nodes[$item['id']] ?? null;

            $tree[$key]['__children'] = $this->fillTreeNodesForItems($tree[$key]['__children'], $nodes);
        }

        return $tree;
    }
205507
public static function toCollections(array $items): array
    {
        foreach ($items as $k => $item) {
            $items[$k] = new static($item);
        }

        return $items;
    }