Grasshopper Interview Question

implement a depth first search algorithm