Implement the same logic using Stream.unfold.