sub genIterator { my @stack = @_; return sub { splice @stack, 0, 1, @{$stack[0]} while 'ARRAY' eq ref $stack[0]; shift @stack; } }