Those kinds of dependency chains look subject to a depth first search like Tarjan's strongly connected components algorithm, at least to my naive first pass reading. I've used it all over the place in e.g. analyzing foreign dependencies in database tables, or makefiles/rakefiles for task dependencies
It's always fun when someone asks an interview question that's even tangentially related and I get to go deep about the relative tradeoffs of a simpler algorithm like Tarjan's/Dijkstra's, over one of the more modern and faster but conceptually more challenging versions.