public function ancestor($route, $path = null)
    {
        if ($path !== null) {
            $page = $this->dispatch($route, true);

            if ($page && $page->path() === $path) {
                return $page;
            }

            $parent = $page ? $page->parent() : null;
            if ($parent && !$parent->root()) {
                return $this->ancestor($parent->route(), $path);
            }
        }

        return null;
    }
public function ancestor($route, $path = null)
    {
        if ($path !== null) {
            $page = $this->dispatch($route, true);

            if ($page && $page->path() === $path) {
                return $page;
            }

            $parent = $page ? $page->parent() : null;
            if ($parent && !$parent->root()) {
                return $this->ancestor($parent->route(), $path);
            }
        }

        return null;
    }
public function ancestor ( $ route , $ path = null ) { if ( $ path !== null ) { $ page = $ this -> dispatch ( $ route , true ) ; if ( $ page && $ page -> path ( ) === $ path ) { return $ page ; } $ parent = $ page ? $ page -> parent ( ) : null ; if ( $ parent && ! $ parent -> root ( ) ) { return $ this -> ancestor ( $ parent -> route ( ) , $ path ) ; } } return null ; }
Get a page ancestor.

@param  string $route The relative URL of the page
@param  string $path The relative path of the ancestor folder

@return PageInterface|null
Get a page ancestor .