/** * @param NodeInterface $node * @return NodeInterface */ private function _addAncestors(NodeInterface $node) { /** @var NodeInterface $ancestorNode */ foreach ($node->getAncestors() as $ancestorNode) { if (!$ancestorNode->getId() || !$this->_idExists($ancestorNode->getId())) { $this->addNode($ancestorNode, null, true); } } return $node; }