protected function lastTagName($node)
    {
        $lastNode = $node->previousSibling;
        while ($lastNode != null) {
            if ($lastNode instanceof DOMElement) {
                break;
            }
            $lastNode = $lastNode->previousSibling;
        }
        $lastTag = '';
        if ($lastNode instanceof DOMElement && $lastNode != null) {
            $lastTag = strtolower($lastNode->nodeName);
        }

        return $lastTag;
    }