def populate_from_sequence(seq: list, r: ref(Edge), sr: state.StateRegister):
base_state = r<EOL>idxlast = len(seq) - <NUM_LIT:1><EOL>idx = <NUM_LIT:0><EOL>for m in seq:<EOL><INDENT>if isinstance(m, list):<EOL><INDENT>for item in m:<EOL><INDENT>populate_from_sequence(item, r, sr)<EOL><DEDENT><DEDENT>elif isinstance(m, MatchExpr):<EOL><INDENT>eX = r().get_next_edge(m)<EOL>if eX is None:<EOL><INDENT>sX = None<EOL>if idx != idxlast:<EOL><INDENT>sX = state.State(sr)<EOL>sX.matchDefault(base_state().s)<EOL><DEDENT>else:<EOL><INDENT>sX = base_state().s<EOL><DEDENT>eX = Edge(sX)<EOL>r().next_edge[id(sX)] = eX<EOL>m.attach(r().s, sX, sr)<EOL><DEDENT>r = ref(eX)<EOL><DEDENT>idx += <NUM_LIT:1><EOL><DEDENT>
function that connect each other one sequence of MatchExpr.