code: def _checkJobGraphAcylicDFS(self, stack, visited, extraEdges):
          
          if self not in visited:
              visited.add(self)
              stack.append(self)
              for successor in self._children + self._followOns + extraEdges[self]:
                  successor._checkJobGraphAcylicDFS(stack, visited, extraEdges)
              assert stack.pop() == self
          if self in stack:
              stack.append(self)
              raise JobGraphDeadlockException("A cycle of job dependencies has been detected '%s'" % stack)
docs: DFS traversal to detect cycles in augmented job graph.