Recursive lists and generators in Python