def remove_unnecessary_merge_gateways(process_dict, bpmn_diagram, sequence_flows):
for node in list(bpmn_diagram.get_nodes()):<EOL><INDENT>gateway_type = node[<NUM_LIT:1>].get(consts.Consts.type)<EOL>if gateway_type in [consts.Consts.inclusive_gateway, consts.Consts.exclusive_gateway,<EOL>consts.Consts.parallel_gateway]:<EOL><INDENT>if len(node[<NUM_LIT:1>].get(consts.Consts.incoming_flow)) < <NUM_LIT:2>and len(node[<NUM_LIT:1>].get(consts.Consts.outgoing_flow)) < <NUM_LIT:2>:<EOL><INDENT>new_source_node, new_target_node = remove_node(node[<NUM_LIT:0>], process_dict, bpmn_diagram, sequence_flows)<EOL>add_connection(new_source_node, new_target_node, process_dict, bpmn_diagram, sequence_flows)<EOL><DEDENT><DEDENT><DEDENT>
:param process_dict:
:param bpmn_diagram:
:param sequence_flows: