private function ensureNodeClass(DOMNode $node)
    {
        $class = $this->nodeClasses['DOMElement'];

        if (true !== ($node instanceof $class) && $node instanceof \DOMElement) {
            return $node->ownerDocument->importNode($node, true);
        }

        return $node;
    }