public function hasAncestor(Element $element) { if ($this->parent === null) { return false; } if ($this->parent->getType() == Token::ELEMENT && $this->parent->getName() == $element->getName()) { return true; } return $this->parent->hasAncestor($element); }