Simple implementation of tail-recursion elimination.