Finding the Cycle
In short: colour every depot white, grey or black as DFS runs: grey means "on the path you're walking right now", black means "finished, nothing below it can lead back to you". An arrow into a grey depot is a back edge, and it closes a loop — the loop is exactly the grey path from that depot down to where you stand. An arrow into a black depot never is a loop, because anything reachable from a black depot was already explored while it was still grey.

When a Meridian depot fills up, it forwards its overflow to another depot. Each depot manager sets their own rule, and nobody looks at all of them together. So one night north forwards to east, east forwards to south, south forwards back to north, and a van of parcels drives in a circle until morning.
Kahn's algorithm from the last lesson could tell you that some loop exists, because loops are what it leaves behind. The operations team wants more than that: which depots, in what order, so someone can phone the right manager. This lesson finds the loop itself, using depth-first search and three colours.
Visited is not enough
The first idea is to run DFS and shout "loop!" the moment you reach a depot you've already visited. Try it on four depots where two routes happen to meet:
after = {"a": ["b", "c"], "b": ["d"], "c": ["d"], "d": []}
visited = set()
def visit(depot):
if depot in visited:
return True # "seen it before, must be a loop"
visited.add(depot)
return any(visit(nxt) for nxt in after[depot])
print(visit("a"))Reaching an old depot tells you two routes meet. It doesn't tell you there's a way back. For that you need to know whether the old depot is still on the path you are walking right now.