def METHOD_NAME(node):
    assert isinstance(node, minidom.Node)
    if len(node.childNodes) == 0:
        # there's no data for this leaf node
        value = None
    elif len(node.childNodes) == 1 and node.childNodes[0].nodeType == node.TEXT_NODE:
        # there is data for this leaf node
        value = node.childNodes[0].nodeValue
    else:
        # this is an internal node
        value = {}
        for child in node.childNodes:
            d = METHOD_NAME(child)
            child_name = child.nodeName
            assert list(d.keys()) == [child_name]
            if child_name not in value:
                # copy the value into the dict
                value[child_name] = d[child_name]
            elif type(value[child_name]) == list:
                # add to the existing list
                value[child_name].append(d[child_name])
            else:
                # create a new list
                value[child_name] = [value[child_name], d[child_name]]
    return {node.nodeName: value}