def root_app(expr):
    """Returns the pair (r, args)
    such that expr = r(*args)
    
    Arguments:
    - `expr`: an expression
    """
    root = expr
    args = []
    while root.is_app():
        args.append(root.arg)
        root = root.fun
        #The arguments were collected in reverse order
    args.reverse()
    return (root, args)