Create a XML subelement from a Python dictionary.

def create_dict_subelement(root, subelement, content, **kwargs):
    """Create a XML subelement from a Python dictionary."""
    attribs = kwargs.get('attribs', None)
    namespace = kwargs.get('namespace', None)
    key = subelement

    # Add subelement's namespace and attributes.
    if namespace and attribs:
        subelement = SubElement(root, namespace + subelement, attribs)
    elif namespace:
        subelement = SubElement(root, namespace + subelement)
    elif attribs:
        subelement = SubElement(root, subelement, attribs)
    # Otherwise, create SubElement without any extra data.
    else:
        subelement = SubElement(root, subelement)
    if not isinstance(content, dict):
        subelement.text = content
    # Do special case ordering for degree children on etd_ms.
    elif key == 'degree':
        for degree_order_key in DEGREE_ORDER:
            for descriptor, value in content.items():
                if descriptor == degree_order_key:
                    sub_descriptors = SubElement(subelement, descriptor)
                    sub_descriptors.text = value
    else:
        for descriptor, value in content.items():
            sub_descriptors = SubElement(subelement, descriptor)
            sub_descriptors.text = value