/** * @return int */ public function getLevel() { if (is_null($this->parent)) { return 0; } return $this->parent->getLevel() + 1; }