The subject invention pertains to systems and methods for iterating over
or otherwise traversing a collection of objects or elements. More
specifically, mechanisms are provided for handling both conventional
non-nested streams such as enumeratables as well as nested streams.
Nested streams provide a more efficient mechanism for traversing certain
objects such as recursive generators. One problem with nested streams is
that they need to be flattened or simplified. Techniques are provided
herein to allow such streams to be flattened quickly and efficiently.
Moreover, systems and methods are disclosed to preserve backward
compatibility of optimized nested stream processing with conventional
non-nested streams.