        sub walk_tree {
          my @todo = @_;
          return sub {
            return unless @todo;    # nothing left

            my $dir = pop @todo;
            if (-d $dir && ! -l $dir && opendir my $dh, $dir) {
              my @subitems = 
                grep {$_ ne '.' && $_ ne '..'} readdir $dh;
              @subitems = map "$dir/$_", @subitems;
              push @todo, @subitems;
            }
            return $dir;
          };
        }

