public function getPath() { $path = array(); $Category = $this; $max = 10; while ($max--) { $path[] = $Category; $Category = $Category->getParent(); if (!$Category || !$Category->getId()) { break; } } return array_reverse($path); }