def extract_path(node, tree):
    """
    Give a node, recursively generate a path of nodes
    back to the root of the tree, effectively generating
    the figure corresponding to this leaf node.
    """
    if node['point'] == [0, 0]:
        return []
    return [node['point']] + extract_path(tree[node['prev_gen']], tree)