def build_path_commands(tree, graph):
    cursor = (0, 0)
    next_node = tree.search_nn(cursor)
    nodes = []
    culled = set()
    while next_node:
        (next_point, distance) = next_node
        next_point = next_point.data
        distance = math.sqrt(distance)
        tree = tree.remove(next_point)
        culled.add(next_point)
        if nodes and distance > 16:
            yield nodes
            nodes = []
        nodes += walk_graph(graph, next_point)
        for node in nodes:
            if node in culled:
                continue
            tree = tree.remove(node) or tree
            culled.add(node)
        next_node = tree.search_nn(nodes[-1])
    if nodes:
        yield nodes
dataset/ETHPy150Open vishnubob/silhouette/printsvg.py/build_path_commands/original