def reverse(node):
    """
    Given the first node in a linked list, return (R, L) where R is the
    linked list in reverse, and L points to last node in that list.
    """
    if node.next is None:
        return (node, node)
    (flipped, tail) = reverse(node.next)
    # Append to tail and return
    tail.next = node
    node.next = None
    return (flipped, node)