public function setChildNodeOf(NodeInterface $node)
 {
     $separator = static::getMaterializedPathSeparator();
     $path = rtrim($node->getRealMaterializedPath(), $separator);
     $this->setMaterializedPath($path);
     // TODO: getSortField
     $sortPath = rtrim($node->getSortMaterializedPath(), $separator);
     $sortString = method_exists($this, 'getSortField') ? $this->getSortField() : (string) $this;
     $this->setSortMaterializedPath($sortPath . $separator . $sortString . $separator . $this->getId());
     if (null !== $this->parentNode) {
         $this->parentNode->getChildNodes()->removeElement($this);
     }
     $this->parentNode = $node;
     $this->parentNode->addChildNode($this);
     foreach ($this->getChildNodes() as $child) {
         $child->setChildNodeOf($this);
     }
     return $this;
 }
 /**
  * {@inheritdoc}
  **/
 public function setChildNodeOf(NodeInterface $node)
 {
     $id = $this->getNodeId();
     if (empty($id)) {
         throw new \LogicException('You must provide an id for this node if you want it to be part of a tree.');
     }
     $path = rtrim($node->getRealMaterializedPath(), static::getMaterializedPathSeparator());
     $this->setMaterializedPath($path);
     if (null !== $this->parentNode) {
         $this->parentNode->getChildNodes()->removeElement($this);
     }
     $this->parentNode = $node;
     $this->parentNode->addChildNode($this);
     foreach ($this->getChildNodes() as $child) {
         $child->setChildNodeOf($this);
     }
     return $this;
 }
 public function getTreeExceptNodeAndItsChildrenQB(NodeInterface $entity, $rootAlias = 't')
 {
     return $this->getFlatTreeQB('', $rootAlias)->andWhere($rootAlias . '.materializedPath NOT LIKE :except_path')->andWhere($rootAlias . '.id != :id')->setParameter('except_path', $entity->getRealMaterializedPath() . '%')->setParameter('id', $entity->getId());
 }