Get a list of this DataObject's and all it's descendants ID, and put them in $idList.

@param array $idList Array to put results in.
@param DataObject|Hierarchy $node
327131
protected function loadDescendantIDListInto(&$idList, $node = null)
    {
        if (!$node) {
            $node = $this->owner;
        }
        $children = $node->AllChildren();
        foreach ($children as $child) {
            if (!in_array($child->ID, $idList)) {
                $idList[] = $child->ID;
                $this->loadDescendantIDListInto($idList, $child);
            }
        }
    }
1125781
private function getParentsIdRec($id, $className, $primaryKey, $parentIdField)
    {
        $parentId = (int)$className::find()->select($parentIdField)->where([ $primaryKey => $id ])->scalar();
        if ( $parentId ) {
            return array_merge(self::getParentsIdRec($parentId, $className, $primaryKey, $parentIdField), [$id]);
        } else {
            return [$id];
        }
    }
31805
public function getInstanceNodes(TreeNodeInterface $node)
    {
        $instanceNodes = [];
        foreach ($this->getAll() as $tree) {
            $instanceNodes = array_merge($instanceNodes, $tree->getInstances($node));
        }

        return $instanceNodes;
    }
739564
public static function get_ancestors( \DOMNode $node ) {
		$result = [];

		while ( ( $node = $node->parentNode ) && ( $node instanceof \DOMElement ) ) { // phpcs:ignore WordPress.CodeAnalysis.AssignmentInCondition.FoundInWhileCondition
			$result[] = $node;
		}

		return $result;
	}
696899
public function getRoot($parentNodeCategory = null, $recursionLevel = 3)
    {
        if ($parentNodeCategory === null) {
            if ($this->getCurrentCategoryId()) {
                $this->getRootByIds([$this->getCurrentCategoryId()]);
            }
        }

        return parent::getRoot($parentNodeCategory, $recursionLevel);
    }
1332984
protected function determineDepth( $node, $nesting = 0 )
	{
		// Traverse back up the ancestry chain and add to the nesting level count
		while ( $parent = $node->parent()->first() )
		{
			$nesting = $nesting + 1;

			$node = $parent;
		}

		return [$node, $nesting];
	}
1014100
static function appendRelatingNodeIDs( $object, &$nodeIDList )
    {
        $viewCacheIni = eZINI::instance( 'viewcache.ini' );
        if ( $viewCacheIni->hasVariable( 'ViewCacheSettings', 'ClearRelationTypes' ) )
        {
            $relTypes = $viewCacheIni->variable( 'ViewCacheSettings', 'ClearRelationTypes' );

            if ( !count( $relTypes ) )
                return;

            $relatedObjects = array();

            $relationsMask = 0;
            if ( in_array( 'object', $relTypes ) )
                $relationsMask |= eZContentObject::RELATION_COMMON | eZContentObject::RELATION_EMBED;

            if ( in_array( 'common', $relTypes ) )
                $relationsMask |= eZContentObject::RELATION_COMMON;

            if ( in_array( 'embedded', $relTypes ) )
                $relationsMask |= eZContentObject::RELATION_EMBED;

            if ( in_array( 'linked', $relTypes ) )
                $relationsMask |= eZContentObject::RELATION_LINK;

            if ( in_array( 'attribute', $relTypes ) )
                $relationsMask |= eZContentObject::RELATION_ATTRIBUTE;

            if ( $relationsMask )
            {
                $objects = $object->relatedContentObjectList( false, false, false, false,
                                                              array( 'AllRelations' => $relationsMask ) );
                $previousVersionObjects = array();
                $previousVersion = $object->previousVersion();
                if ( $previousVersion )
                {
                    $previousVersionObjects = $object->relatedContentObjectList( $previousVersion, false, false, false,
                                                              array( 'AllRelations' => $relationsMask ) );
                }
                $relatedObjects = array_merge( $relatedObjects, $objects, $previousVersionObjects );
            }

            $relationsMask = 0;
            if ( in_array( 'reverse_object', $relTypes ) )
                $relationsMask |= eZContentObject::RELATION_COMMON | eZContentObject::RELATION_EMBED;

            if ( in_array( 'reverse_common', $relTypes ) )
                $relationsMask |= eZContentObject::RELATION_COMMON;

            if ( in_array( 'reverse_embedded', $relTypes ) )
                $relationsMask |= eZContentObject::RELATION_EMBED;

            if ( in_array( 'reverse_linked', $relTypes ) )
                $relationsMask |= eZContentObject::RELATION_LINK;

            if ( in_array( 'reverse_attribute', $relTypes ) )
                $relationsMask |= eZContentObject::RELATION_ATTRIBUTE;

            if ( $relationsMask )
            {
                $objects = $object->reverseRelatedObjectList( false, false, false,
                                                              array( 'AllRelations' => $relationsMask ) );
                $previousVersionObjects = array();
                $previousVersion = $object->previousVersion();
                if ( $previousVersion )
                {
                    $previousVersionObjects = $object->relatedContentObjectList( $previousVersion, false, false, false,
                                                              array( 'AllRelations' => $relationsMask ) );
                }
                $relatedObjects = array_merge( $relatedObjects, $objects, $previousVersionObjects );
            }
        }
        else
        {
            $normalRelated = $object->relatedContentObjectArray();
            $reversedRelated = $object->contentObjectListRelatingThis();

            $relatedObjects = array_merge( $normalRelated, $reversedRelated );
        }

        foreach ( $relatedObjects as $relatedObject )
        {
            $assignedNodes = $relatedObject->assignedNodes( false );
            foreach ( $assignedNodes as $assignedNode )
            {
                $nodeIDList[] = $assignedNode['node_id'];
            }
        }
        $nodeIDList = array_unique( $nodeIDList );
    }
957228
public function getInternalLinks( \DOMNode $node ) : array
	{
		$this->guardHasOwnerDocument( $node );

		$internalLinks = [];
		$xpath         = new \DOMXPath( $node->ownerDocument );
		$aTags         = $xpath->query( '*//a[@href]' );

		/** @var \DOMElement $aTag */
		foreach ( $aTags as $aTag )
		{
			$href = $aTag->getAttribute( 'href' );
			if ( !$this->isHyperRefIgnored( $href ) )
			{
				$internalLinks[] = $aTag;
			}
		}

		return $internalLinks;
	}
699628
private static <T extends HierarchyEntity<T, ?>> void loadChildren(T node, Set<T> children) {
    if (null == node.getChildren()) { return; }
    for (T one : node.getChildren()) {
      children.add(one);
      loadChildren(one, children);
    }
  }
1006970
protected function getChildrenCategoriesRecursive($idList, $counter = 0): string
    {
        $result = [];

        // add id list to the output
        if ($counter === 0) {
            $newList = $this->getUidListFromRecords($idList);
            if ($newList) {
                $result[] = $newList;
            }
        }

        $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
            ->getQueryBuilderForTable('sys_category');
        $res = $queryBuilder
            ->select('uid')
            ->from('sys_category')
            ->where(
                $queryBuilder->expr()->in('parent', $queryBuilder->createNamedParameter(explode(',', $idList), Connection::PARAM_INT_ARRAY))
            )
            ->execute();

        while ($row = $res->fetch()) {
            $counter++;
            if ($counter > 10000) {
                $this->timeTracker->setTSlogMessage('EXT:tt_address: one or more recursive categories where found');
                return implode(',', $result);
            }
            $subcategories = $this->getChildrenCategoriesRecursive($row['uid'], $counter);
            $result[] = $row['uid'] . ($subcategories ? ',' . $subcategories : '');
        }

        $result = implode(',', $result);
        return $result;
    }
1061406
protected function getParentsHierarchyField($dataObject) {
		
		// see if we've got Parent values
		if (is_object($dataObject) && method_exists($dataObject, 'hasField') && $dataObject->hasField('ParentID')) {
			$parentsField = array('Type' => '', 'Value' => null);
			$parents = array();
			
			$parent = $dataObject;
			while ($parent && $parent->ParentID) {
				$parents[] = $parent->ParentID;
				$parent = $parent->Parent();
				// fix for odd behaviour - in some instance a node is being assigned as its own parent. 
				if ($parent->ParentID == $parent->ID) {
					$parent = null;
				}
			}
			$parentsField['Value'] = $parents;
			return $parentsField;
		}
	}
684137
private function recursiveCallChild(\DOMNodeList $nodeList, callable $fct)
    {
        /**
         * @var \DOMNode $domNode
         */
        foreach ($nodeList as $domNode) {
            $fct(new GlHtmlNode($domNode));
            if ($domNode->hasChildNodes()) {
                $this->recursiveCallChild($domNode->childNodes, $fct);
            }
        }
    }
264882
static function fetchListByID( $idList ,$asObject = true )
    {
        $cond = array( 'id' => array( $idList ) );
        return eZPersistentObject::fetchObjectList( eZNodeAssignment::definition(),
                                                    null, $cond, null, null,
                                                    $asObject );
    }
369700
public function getChildrenCategories($idList, int $counter = 0)
    {
        $cacheIdentifier = sha1('children' . $idList);

        $entry = $this->cache->get($cacheIdentifier);
        if (!$entry) {
            $entry = $this->getChildrenCategoriesRecursive($idList, $counter);
            $this->cache->set($cacheIdentifier, $entry);
        }

        return $entry;
    }
724826
protected function getNodeAliasMap(array $nodeIdList) : array
    {
        return $this
            ->database
            ->select('ucms_seo_node', 'n')
            ->fields('n', ['nid', 'alias_segment'])
            ->condition('n.nid', $nodeIdList)
            ->execute()
            ->fetchAllKeyed()
        ;
    }
621314
protected List<NodeData> getDirectChildNodesData(NodeData parent, List<QPathEntryFilter> itemDataFilters)
      throws RepositoryException, IllegalStateException
   {
      checkIfOpened();
      if (itemDataFilters.isEmpty())
      {
         return new ArrayList<NodeData>();
      }

      List<NodeData> children = new ArrayList<NodeData>();
      for (Iterator<QPathEntryFilter> it = itemDataFilters.iterator(); it.hasNext(); )
      {
         QPathEntryFilter filter = it.next();
         if (filter.isExactName())
         {
            NodeData data = (NodeData)getItemData(parent, filter.getQPathEntry(), ItemType.NODE);
            if (data != null)
            {
               children.add(data);
            }
            it.remove();
         }
      }
      if (!itemDataFilters.isEmpty())
      {
         children.addAll(getChildNodesDataInternal(parent, itemDataFilters));
      }
      return children;
   }
580987
public static <T extends HierarchyEntity<T, ?>> List<T> getRoots(final List<T> nodes) {
    List<T> roots = CollectUtils.newArrayList();
    for (T m : nodes)
      if (null == m.getParent() || !nodes.contains(m.getParent())) roots.add(m);
    return roots;
  }