Implementation for nested generators.