def are_equal_elements(a_el, b_el):
    """Normalize and compare ElementTrees for equality.

    Args:
      a_el: ElementTree
      b_el: ElementTree
        ElementTrees to compare for equality.

    Returns:
      bool: ``True`` if the ElementTrees are semantically equivalent.

    """
    if a_el.tagName != b_el.tagName:
        return False
    if sorted(a_el.attributes.items()) != sorted(b_el.attributes.items()):
        return False
    if len(a_el.childNodes) != len(b_el.childNodes):
        return False
    for a_child_el, b_child_el in zip(a_el.childNodes, b_el.childNodes):
        if a_child_el.nodeType != b_child_el.nodeType:
            return False
        if (
            a_child_el.nodeType == a_child_el.TEXT_NODE
            and a_child_el.data != b_child_el.data
        ):
            return False
        if a_child_el.nodeType == a_child_el.ELEMENT_NODE and not are_equal_elements(
            a_child_el, b_child_el
        ):
            return False
    return True
def are_equal_elements ( a_el , b_el ) : if a_el . tagName != b_el . tagName : return False if sorted ( a_el . attributes . items ( ) ) != sorted ( b_el . attributes . items ( ) ) : return False if len ( a_el . childNodes ) != len ( b_el . childNodes ) : return False for a_child_el , b_child_el in zip ( a_el . childNodes , b_el . childNodes ) : if a_child_el . nodeType != b_child_el . nodeType : return False if ( a_child_el . nodeType == a_child_el . TEXT_NODE and a_child_el . data != b_child_el . data ) : return False if a_child_el . nodeType == a_child_el . ELEMENT_NODE and not are_equal_elements ( a_child_el , b_child_el ) : return False return True
Normalize and compare ElementTrees for equality.

    Args:
      a_el: ElementTree
      b_el: ElementTree
        ElementTrees to compare for equality.

    Returns:
      bool: ``True`` if the ElementTrees are semantically equivalent.