shouldn't this be like a "toListOrderedByDependencies" or similar ?

I still don't grok why you need to mutate the incoming set and loop "infinitely" instead of just skipping projects you've already seen ?