def detect_cycle(graph):
visited_nodes = set()<EOL>for node in list(graph):<EOL><INDENT>if node not in visited_nodes:<EOL><INDENT>cycle = _dfs_cycle_detect(graph, node, [node], visited_nodes)<EOL>if cycle:<EOL><INDENT>return cycle<EOL><DEDENT><DEDENT><DEDENT>return None<EOL>
search the given directed graph for cycles

returns None if the given graph is cycle free
otherwise it returns a path through the graph that contains a cycle
:param graph:
:return: