public function ancestorByTag($tag)
{
// Start by including ourselves in the comparison.
$node = $this;
while (!is_null($node)) {
if ($node->tag->name() == $tag) {
return $node;
}
$node = $node->getParent();
}
throw new ParentNotFoundException('Could not find an ancestor with "' . $tag . '" tag');
}