Correctly set pending_dirs to support walking subdirectories recursively.