def METHOD_NAME(self, root: Any, k: str, v: Any,
                 key_attr: Optional[Any] = None):
    element = SubElement(root, k)
    if v is None:
        element.attrib[u'xsi:nil'] = u'true'
    elif not isinstance(v, (list, dict)):
        element.text = str(v)
    else:
        if isinstance(v, list):
            it = enumerate(v)
        else:
            it = v.items()
        for key, value in it:
            self.METHOD_NAME(element, self._value_tag, value, key)
    if key_attr is not None:
        element.attrib[self._key_attr] = str(key_attr)