def _remove_elements(self, elts_to_remove):
        """
        Removes flagged elements from the ElementTree
        """
        for e in elts_to_remove:

            # Get the element parent
            parent = e.getparent()

            # lxml also remove the element tail, preserve it
            if e.tail and e.tail.strip():
                parent_text = parent.text or ''
                parent.text = parent_text + e.tail

            # Remove the element
            e.getparent().remove(e)
Removes flagged elements from the ElementTree