def bottom_up(rv, F, atoms=False, nonbasic=False):
    try:
        if rv.args:
            args = tuple([bottom_up(a, F, atoms, nonbasic)
                for a in rv.args])
            if args != rv.args:
                rv = rv.func(*args)
            rv = F(rv)
        elif atoms:
            rv = F(rv)
    except AttributeError:
        if nonbasic:
            try:
                rv = F(rv)
            except TypeError:
                pass

    return rv
Apply ``F`` to all expressions in an expression tree from the
dataset/ETHPy150Open sympy/sympy/sympy/simplify/simplify.py/bottom_up