import copy


def _clean_root(tool_xml):
    """XSD assumes macros have been expanded, so remove them."""
    clean_tool_xml = copy.deepcopy(tool_xml)
    to_remove = []
    for macros_el in clean_tool_xml.getroot().findall("macros"):
        to_remove.append(macros_el)
    for macros_el in to_remove:
        clean_tool_xml.getroot().remove(macros_el)
    return clean_tool_xml