Solution to reverse_iterate