protected function _addChildNode($oXml, $sKey, $mElement, $sPreferredKey = null)
    {
        $aAttributes = [];
        if (is_array($mElement) && array_key_exists('attributes', $mElement) && is_array($mElement['attributes'])) {
            $aAttributes = $mElement['attributes'];
            $mElement = $mElement['value'];
        }

        if (is_object($mElement) || is_array($mElement)) {
            if (is_int(key($mElement))) {
                $this->_addSimpleXmlElement($oXml, $mElement, $sKey);
            } else {
                $oChildNode = $oXml->addChild($sPreferredKey? $sPreferredKey : $sKey);
                $this->_addNodeAttributes($oChildNode, $aAttributes);
                $this->_addSimpleXmlElement($oChildNode, $mElement);
            }
        } else {
            $oChildNode = $oXml->addChild($sPreferredKey? $sPreferredKey : $sKey, $mElement);
            $this->_addNodeAttributes($oChildNode, $aAttributes);
        }

        return $oXml;
    }