/** * Sets the parent node. * * @param InnerNode $parent * @return $this * @throws CircularException */ public function setParent(InnerNode $parent) { // remove from old parent if (!is_null($this->parent)) { if ($this->parent->id() == $parent->id()) { // already the parent return $this; } $this->parent->removeChild($this->id); } $this->parent = $parent; // assign child to parent $this->parent->addChild($this); //clear any cache $this->clear(); return $this; }