Prevent entering directories multiple times.