/** * Gets the nodes depth. * * @return int */ public function getDepth() { if ($this->parent === null) { return 0; } return $this->parent->getDepth() + 1; }