private function appendDOMNode(\DOMDocument $dom, $node, $name, $value = null, $hasAttributes = false)
    {
        $element = $dom->createElement($name);

        if ($hasAttributes && $this->nodeValueKey === $name) {
            $this->setElementValue($dom, $node, $value);

            return;
        }

        $this->setElementValue($dom, $element, $value);
        $node->appendChild($element);
    }