protected function setParent(Directory $parent) { if ($this->parent) { $this->parent->removeChild($this); } $parent->addChild($this); $this->parent = $parent; }