public function getChild(
        SimpleXMLElement $element,
        $name,
        array $attributes = []
    ) {
        $xpath = $name . $this->getAttributesXpath($attributes);

        $result = $element->xpath($xpath);
        if (empty($result)) {
            $node = $element->addChild($name);
            $this->setAttributes($node, $attributes);
        } else {
            $node = reset($result);
        }

        return $node;
    }