Fix #15862 remove dirs in keep list when walk path

It would not, since it is not being iterated over yet, you still need to iterate over "dirs", as we see on the next line