def html_tree_equal(received, expected):
    """
    Returns whether two etree Elements are the same, with insensitivity to attribute order.
    """
    for attr in ('tag', 'attrib', 'text', 'tail'):
        if getattr(received, attr) != getattr(expected, attr):
            return False
    if len(received) != len(expected):
        return False
    if any(not html_tree_equal(rec, exp) for rec, exp in zip(received, expected)):
        return False
    return True