/** * Returns the root container of the given page * * When rendering a container, the render method still store the given * container as the root container, and unset it when done rendering. This * makes sure finder methods will not traverse above the container given * to the render method. * * @param Zend_Navigaiton_Page $page page to find root for * @return Zend_Navigation_Container the root container of the given page */ protected function _findRoot(Zend_Navigation_Page $page) { if ($this->_root) { return $this->_root; } $root = $page; while ($parent = $page->getParent()) { $root = $parent; if ($parent instanceof Zend_Navigation_Page) { $page = $parent; } else { break; } } return $root; }