5.2: How to Convert a Recursive Function to an Iterator