code: def dfs(graph, func, head, reverse=None):
      
      todo = deque()
      todo.append(head)
      path = deque()
      done = set()
      while todo:
          node = todo.popleft()
          if node in done:
              path.pop()
              continue
  
          done.add(node)
          path.append(node)
          result = func(node, path, graph)
          if result:
              if reverse:
                  children = graph.get_parents(node)
              else:
                  children = graph.get_children(node)
              todo.extend(children)
docs: DEPTH FIRST SEARCH
  
      IF func RETURNS FALSE, THEN PATH IS NO LONGER TAKEN
  
      IT'S EXPECTED func TAKES 3 ARGUMENTS
      node - THE CURRENT NODE IN THE
      path - PATH FROM head TO node
      graph - THE WHOLE GRAPH