Flexport interview question

Question about traversing a directed graph