Fix #15862 remove dirs in keep list when walk path

So why is it a copy?

I might need to dig the differences between

dirs[:] = ...
And

dirs_copy = dirs[:]