def METHOD_NAME(tree: ET.ElementTree, remove_attributes=[]) -> ElementTree:
    """Recursively remove all empty nodes and elements containing only empty nodes
    Args:
        xml_tree (ElementTree): tree of the xml file
        remove_attributes (list): list of xml attributes to remove
    """
    def is_empty(elem: Element) -> bool:
        """returns true if elem does not have text
        Args:
            elem (Element): xml element
        Returns:
            bool true if e is empty
        """
        return (elem.text is None) or (elem.text.strip() == '')
    def recursively_remove_empty_elements(elem: Element):
        """reccursive function that remove empty elements
        Args:
            e (Element): xml element
        Returns:
            bool: True if we need to remove the element False otherwise
        """
        # recursive call that gets a list of :
        # [] if e doens't have children
        # [True, False, False, True ] where each bool indicate if e children are empty or not
        child_bool = list(recursively_remove_empty_elements(c) for c in elem.iterchildren())
        nchildren = len(child_bool)
        # there is an issue with the last element
        # so we need to catch the exception
        try:
            # if e doesn't have kids, i.e. it's a leaf
            # remove e if it doesn't have text and returns True
            # keep e if it has text and return False
            if nchildren == 0:
                if is_empty(elem):
                    elem.getparent().remove(elem)
                    return True
                else:
                    return False
            # remove e if all its children have no text
            # and returns True
            elif all(child_bool):
                elem.getparent().remove(elem)
                return True
        # excpetion for root ...
        except:
            return False
    # remove attributes if any are passed
    etree.strip_attributes(tree, remove_attributes)
    # remove the empties
    recursively_remove_empty_elements(tree.getroot())
    return tre