(fn, args, **kwargs)
return fn(make_binary_tree(fn, args[:half], **kwargs),
              make_binary_tree(fn, args[half:], **kwargs), **kwargs)
Takes a function/class that takes two positional arguments and a list of
    arguments and returns a binary tree of results/instances.

    >>> make_binary_tree(UnionMatcher, [matcher1, matcher2, matcher3])
    UnionMatcher(matcher1, UnionMatcher(matcher2, matcher3))

    Any keyword arguments given to this function are passed to the class
    initializer.
Takes a function/class that takes two positional arguments and a list of
    arguments and returns a binary tree of results/instances.
Takes a function / class that takes two positional arguments and a list of arguments and returns a binary tree of results / instances .
def make_binary_tree(fn, args, **kwargs):
    """Takes a function/class that takes two positional arguments and a list of
    arguments and returns a binary tree of results/instances.

    >>> make_binary_tree(UnionMatcher, [matcher1, matcher2, matcher3])
    UnionMatcher(matcher1, UnionMatcher(matcher2, matcher3))

    Any keyword arguments given to this function are passed to the class
    initializer.
    """

    count = len(args)
    if not count:
        raise ValueError("Called make_binary_tree with empty list")
    elif count == 1:
        return args[0]

    half = count // 2
    return fn(make_binary_tree(fn, args[:half], **kwargs),
              make_binary_tree(fn, args[half:], **kwargs), **kwargs)
def make_binary_tree ( fn , args , * * kwargs ) : count = len ( args ) if not count : raise ValueError ( "Called make_binary_tree with empty list" ) elif count == 1 : return args [ 0 ] half = count // 2 return fn ( make_binary_tree ( fn , args [ : half ] , * * kwargs ) , make_binary_tree ( fn , args [ half : ] , * * kwargs ) , * * kwargs )