def broadcast_collect(expr,
                      broadcastable=Broadcastable,
                      want_to_broadcast=WantToBroadcast,
                      no_recurse=None):
    if (isinstance(expr, want_to_broadcast) and
            iscollection(expr.dshape)):
        leaves = leaves_of_type(broadcastable, expr)
        expr = broadcast(expr, sorted(leaves, key=str))

    if no_recurse is not None and isinstance(expr, no_recurse):
        return expr

    # Recurse down
    children = (
        broadcast_collect(i, broadcastable, want_to_broadcast, no_recurse)
        for i in expr._inputs
    )
    return expr._subs({e: c for e, c in zip(expr._inputs, children)})
Collapse expression down using Broadcast - Tabular cases only
dataset/ETHPy150Open blaze/blaze/blaze/expr/broadcast.py/broadcast_collect