Prevent entering directories multiple times.

This means that if something depends on something from a sub directory,
it needs to list it as a dependency now.