<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def move(g, n1, n2, **kwargs):
 """ Step along a graph until it ends or reach 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 [1, 2, 3, 5] # Stops at 5 because you can get to both 6 and 7 from 3 [1, 2, 3] Parameters Same as step() Yields ------ Node IDs until either there is no path forward or the path reaches an intersection """

    prev = n1
    curr = n2
    _next = step(g, prev, curr, **kwargs)

    yield prev
    yield curr

    visited_nodes = set([prev, curr])
    while _next:
        yield _next
        if _next in visited_nodes:
            return
        visited_nodes.add(_next)
        prev = curr
        curr = _next
        _next = step(g, prev, curr, **kwargs)