Reduce redundant walks when resolving module depends_on
#35157
+28
−13
Merged