public function getParent($id = 0) { foreach ($this->menu as $item) { if ($item->getId() == $id) { return $this; } elseif ($i = $item->getParent($id)) { return $i; } } }