private static function getOrCreateNode(DOMElement $svg, $tagName, $value)
    {
        $node = $svg->getElementsByTagName($tagName);

        if ($node->length) {
            $node = $node->item(0);
            $node->nodeValue = $value;
            
            return $node;
        }

        $newNode = new DOMElement($tagName, $value);
        $svg->appendChild($newNode);

        return $newNode;
    }