original_string: 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;
      }
code: 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;
      }
code_tokens: 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 ; }
docstring: 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
docstring_tokens: Get a page ancestor .