def _explore_capture(explore, g, node):
    """
    Adds the capture flags on the edges around the node. Of another capture
    is already flagged, append to the list.
    """
    explore.add(node.statement)
    g.add_node(node.statement)
    for p in g.predecessors(node):
        data = g.get_edge_data(p, node, default={'start_captures': []})
        data['start_captures'] = [*data.get('start_captures', []), node]
        g.add_edge(p, node.statement, **data)
    for s in g.successors(node):
        data = g.get_edge_data(node, s, default={'stop_captures': []})
        data['stop_captures'] = [node, *data.get('stop_captures', [])]
        g.add_edge(node.statement, s, **data)
    g.remove_node(node)
