def lower_tree(tree):
    """
    Change all element names and attribute names to lower case.
    """

    root = tree.getroot()

    for node in root.iter():
        node.tag = node.tag.lower()

        attributes = dict()

        for attribute in node.attrib:
            attributes[attribute.lower()] = node.attrib[attribute]

        node.attrib = attributes

    tree._setroot(root)

    return tree