def METHOD_NAME(operator, seq, initializer=NOT_SET):
    """
    Has the same result as Python's reduce function, but performs the calculations in a different order.
    This is important when the operator is constructing data structures such as search query classes.
    This method will make the resulting data structures flatter, so operations that need to traverse
    them don't end up crashing with recursion errors.
    For example:
    Python's builtin reduce() function will do the following calculation:
    reduce(add, [1, 2, 3, 4, 5, 6, 7, 8])
    (1 + (2 + (3 + (4 + (5 + (6 + (7 + 8)))))))
    When using this with query classes, it would create a large data structure with a depth of 7
    Whereas balanced_reduce will execute this like so:
    balanced_reduce(add, [1, 2, 3, 4, 5, 6, 7, 8])
    ((1 + 2) + (3 + 4)) + ((5 + 6) + (7 + 8))
    Which only has a depth of 2
    """
    # Casting all iterables to list makes the implementation simpler
    if not isinstance(seq, list):
        seq = list(seq)
    # Note, it needs to be possible to use None as an initial value
    if initializer is not NOT_SET:
        if len(seq) == 0:
            return initializer
        else:
            return operator(initializer, METHOD_NAME(operator, seq))
    if len(seq) == 0:
        raise TypeError("reduce() of empty sequence with no initial value")
    elif len(seq) == 1:
        return seq[0]
    else:
        break_point = len(seq) // 2
        first_set = METHOD_NAME(operator, seq[:break_point])
        second_set = METHOD_NAME(operator, seq[break_point:])
        return operator(first_set, second_set)