<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def step(g, n1, n2, inbound=False, backward=False, continue_fn=None):
 """ Step along a path through a directed graph unless there is an intersection Example graph: Note that edge (1, 2) and (2, 3) are bidirectional, i.e., (2, 1) and (3, 2) are also edges 1 -- 2 -- 3 -->-- 5 -->-- 7 | | ^ v | | 4 6 3 None 5 None 3 if n2 == 5: return 7 return None 7 Parameters g : networkx DiGraph n1 : node id in g n2 : node id in g (n1, n2) must be an edge in g inbound : bool (default False) whether incoming edges should be considered backward : bool (default False) whether edges are in reverse order (i.e., point from n2 to n1) continue_fn : callable (optional) if at an intersection, continue_fn is called to indicate how to proceed continue_fn takes the form: f(g, n1, n2, backward) where all arguments are as passed into step. f should return a node id such that f(g, n1, n2, backward) is a successors of n2. f should return None if no way forward. Returns ------- The next node in the path from n1 to n2. Returns None if there are no edges from n2 or multiple edges from n2 """

    forw = g.successors
    back = g.predecessors
    if backward:
        back, forw = forw, back

    nodes = forw(n2)
    if inbound:
        nodes = set(nodes + back(n2))
    candidates = [n for n in nodes if n != n1]

    if len(candidates) == 1:
        result = candidates[0]
    elif continue_fn:
        result = continue_fn(g, n1, n2, backward)
    else:
        result = None
    return result