def output_component(graph, edge_stack, u, v):
    """Helper function to pop edges off the stack and produce a list of them."""
    edge_list = []
    while len(edge_stack) > 0:
        edge_id = edge_stack.popleft()
        edge_list.append(edge_id)

        edge = graph.get_edge(edge_id)
        tpl_a = (u, v)
        tpl_b = (v, u)
        if tpl_a == edge['vertices'] or tpl_b == edge['vertices']:
            break

    return edge_list
Helper function to pop edges off the stack and produce a list of them.