def remove_namespaces(tree):
    """Remove namespaces from all elements in the tree."""
    import re
    for elem in tree.iter():
        if isinstance(elem.tag, ''.__class__):
            elem.tag = re.sub('^\\{[^}]*\\}', '', elem.tag)
