protected function isAncestor($tagname) {
        $candidate = $this->current;
        while ($candidate->nodeType === XML_ELEMENT_NODE) {
            if ($candidate->tagName == $tagname) {
                return true;
            }
            $candidate = $candidate->parentNode;
        }

        return false;
    }