def topological_sort(bpmn_graph, nodes_with_classification):
node_param_name = "<STR_LIT>"<EOL>classification_param_name = "<STR_LIT>"<EOL>tmp_nodes_with_classification = copy.deepcopy(nodes_with_classification)<EOL>sorted_nodes_with_classification = []<EOL>no_incoming_flow_nodes = []<EOL>backward_flows = []<EOL>while tmp_nodes_with_classification:<EOL><INDENT>for node_with_classification in tmp_nodes_with_classification:<EOL><INDENT>incoming_list = node_with_classification[node_param_name][<NUM_LIT:1>][consts.Consts.incoming_flow]<EOL>if len(incoming_list) == <NUM_LIT:0>:<EOL><INDENT>no_incoming_flow_nodes.append(node_with_classification)<EOL><DEDENT><DEDENT>if len(no_incoming_flow_nodes) > <NUM_LIT:0>:<EOL><INDENT>while len(no_incoming_flow_nodes) > <NUM_LIT:0>:<EOL><INDENT>node_with_classification = no_incoming_flow_nodes.pop()<EOL>tmp_nodes_with_classification.remove(node_with_classification)<EOL>sorted_nodes_with_classification.append(next(tmp_node for tmp_node in nodes_with_classification<EOL>if tmp_node[node_param_name][<NUM_LIT:0>] == node_with_classification[node_param_name][<NUM_LIT:0>]))<EOL>outgoing_list = list(node_with_classification[node_param_name][<NUM_LIT:1>][consts.Consts.outgoing_flow])<EOL>tmp_outgoing_list = list(outgoing_list)<EOL>for flow_id in tmp_outgoing_list:<EOL><INDENT>'''<STR_LIT>'''<EOL>outgoing_list.remove(flow_id)<EOL>node_with_classification[node_param_name][<NUM_LIT:1>][consts.Consts.outgoing_flow].remove(flow_id)<EOL>flow = bpmn_graph.get_flow_by_id(flow_id)<EOL>target_id = flow[<NUM_LIT:2>][consts.Consts.target_ref]<EOL>target = next(tmp_node[node_param_name]<EOL>for tmp_node in tmp_nodes_with_classification<EOL>if tmp_node[node_param_name][<NUM_LIT:0>] == target_id)<EOL>target[<NUM_LIT:1>][consts.Consts.incoming_flow].remove(flow_id)<EOL><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>for node_with_classification in tmp_nodes_with_classification:<EOL><INDENT>if "<STR_LIT>" in node_with_classification[classification_param_name]:<EOL><INDENT>incoming_list = list(node_with_classification[node_param_name][<NUM_LIT:1>][consts.Consts.incoming_flow])<EOL>tmp_incoming_list = list(incoming_list)<EOL>for flow_id in tmp_incoming_list:<EOL><INDENT>incoming_list.remove(flow_id)<EOL>flow = bpmn_graph.get_flow_by_id(flow_id)<EOL>source_id = flow[<NUM_LIT:2>][consts.Consts.source_ref]<EOL>source = next(tmp_node[node_param_name]<EOL>for tmp_node in tmp_nodes_with_classification<EOL>if tmp_node[node_param_name][<NUM_LIT:0>] == source_id)<EOL>source[<NUM_LIT:1>][consts.Consts.outgoing_flow].remove(flow_id)<EOL>target_id = flow[<NUM_LIT:2>][consts.Consts.target_ref]<EOL>target = next(tmp_node[node_param_name]<EOL>for tmp_node in tmp_nodes_with_classification<EOL>if tmp_node[node_param_name][<NUM_LIT:0>] == target_id)<EOL>target[<NUM_LIT:1>][consts.Consts.incoming_flow].remove(flow_id)<EOL>backward_flows.append(flow)<EOL><DEDENT><DEDENT><DEDENT><DEDENT><DEDENT>return sorted_nodes_with_classification, backward_flows<EOL>
:return: