Hadrian Interview Question

Traverse a directed acyclic graph in Python