def place_element_in_grid(node_with_classification, grid, last_row, last_col, bpmn_graph, nodes_with_classification,<EOL>enforced_row_num=None):
node_param_name = "<STR_LIT>"<EOL>classification_param_name = "<STR_LIT>"<EOL>node_id = node_with_classification[node_param_name][<NUM_LIT:0>]<EOL>incoming_flows = node_with_classification[node_param_name][<NUM_LIT:1>][consts.Consts.incoming_flow]<EOL>outgoing_flows = node_with_classification[node_param_name][<NUM_LIT:1>][consts.Consts.outgoing_flow]<EOL>if len(incoming_flows) == <NUM_LIT:0>:<EOL><INDENT>current_element_row = last_row<EOL>current_element_col = last_col<EOL>if enforced_row_num:<EOL><INDENT>insert_into_grid(grid, enforced_row_num, current_element_col, node_id)<EOL><DEDENT>else:<EOL><INDENT>insert_into_grid(grid, current_element_row, current_element_col, node_id)<EOL><DEDENT>last_row += consts.Consts.grid_column_width<EOL><DEDENT>elif "<STR_LIT>" not in node_with_classification[classification_param_name]:<EOL><INDENT>flow_id = incoming_flows[<NUM_LIT:0>]<EOL>flow = bpmn_graph.get_flow_by_id(flow_id)<EOL>predecessor_id = flow[<NUM_LIT:2>][consts.Consts.source_ref]<EOL>predecessor_cell = next(grid_cell for grid_cell in grid if grid_cell.node_id == predecessor_id)<EOL>current_element_col = predecessor_cell.col + <NUM_LIT:1><EOL>current_element_row = predecessor_cell.row<EOL>if enforced_row_num is not None:<EOL><INDENT>insert_into_grid(grid, enforced_row_num, current_element_col, node_id)<EOL><DEDENT>else:<EOL><INDENT>insert_into_grid(grid, current_element_row, current_element_col, node_id)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>predecessors_id_list = []<EOL>for flow_id in incoming_flows:<EOL><INDENT>flow = bpmn_graph.get_flow_by_id(flow_id)<EOL>predecessors_id_list.append(flow[<NUM_LIT:2>][consts.Consts.source_ref])<EOL><DEDENT>max_col_num = <NUM_LIT:0><EOL>row_num_sum = <NUM_LIT:0><EOL>for grid_cell in grid:<EOL><INDENT>if grid_cell.node_id in predecessors_id_list:<EOL><INDENT>row_num_sum += grid_cell.row<EOL>if grid_cell.col > max_col_num:<EOL><INDENT>max_col_num = grid_cell.col<EOL><DEDENT><DEDENT><DEDENT>current_element_row = row_num_sum // len(predecessors_id_list)<EOL>current_element_col = max_col_num + <NUM_LIT:1><EOL>if enforced_row_num:<EOL><INDENT>insert_into_grid(grid, enforced_row_num, current_element_col, node_id)<EOL><DEDENT>else:<EOL><INDENT>insert_into_grid(grid, current_element_row, current_element_col, node_id)<EOL><DEDENT><DEDENT>if "<STR_LIT>" in node_with_classification[classification_param_name]:<EOL><INDENT>successors_id_list = []<EOL>for flow_id in outgoing_flows:<EOL><INDENT>flow = bpmn_graph.get_flow_by_id(flow_id)<EOL>successors_id_list.append(flow[<NUM_LIT:2>][consts.Consts.target_ref])<EOL><DEDENT>num_of_successors = len(successors_id_list)<EOL>successor_node_list = [successor_node for successor_node in nodes_with_classification<EOL>if successor_node[node_param_name][<NUM_LIT:0>] in successors_id_list]<EOL>if num_of_successors % <NUM_LIT:2> != <NUM_LIT:0>:<EOL><INDENT>centre = (num_of_successors // <NUM_LIT:2>)<EOL>for index in range(<NUM_LIT:0>, centre):<EOL><INDENT>successor_node = successor_node_list[index]<EOL>(grid, last_row, last_col) = place_element_in_grid(successor_node, grid, last_row, last_col,<EOL>bpmn_graph,nodes_with_classification, current_element_row + ((index + <NUM_LIT:1>) * consts.Consts.grid_column_width))<EOL>nodes_with_classification.remove(successor_node)<EOL><DEDENT>successor_node = successor_node_list[centre]<EOL>(grid, last_row, last_col) = place_element_in_grid(successor_node, grid, last_row, last_col,<EOL>bpmn_graph,nodes_with_classification, current_element_row)<EOL>nodes_with_classification.remove(successor_node)<EOL>for index in range(centre + <NUM_LIT:1>, num_of_successors):<EOL><INDENT>successor_node = successor_node_list[index]<EOL>(grid, last_row, last_col) = place_element_in_grid(successor_node, grid, last_row, last_col,<EOL>bpmn_graph,nodes_with_classification, current_element_row - ((index - centre) * consts.Consts.grid_column_width))<EOL>nodes_with_classification.remove(successor_node)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>centre = (num_of_successors // <NUM_LIT:2>)<EOL>for index in range(<NUM_LIT:0>, centre):<EOL><INDENT>successor_node = successor_node_list[index]<EOL>(grid, last_row, last_col) = place_element_in_grid(successor_node, grid, last_row, last_col,<EOL>bpmn_graph,nodes_with_classification, current_element_row + (index + <NUM_LIT:1>) * consts.Consts.grid_column_width)<EOL>nodes_with_classification.remove(successor_node)<EOL><DEDENT>for index in range(centre, num_of_successors):<EOL><INDENT>successor_node = successor_node_list[index]<EOL>(grid, last_row, last_col) = place_element_in_grid(successor_node, grid, last_row, last_col,<EOL>bpmn_graph,nodes_with_classification, current_element_row - ((index - centre + <NUM_LIT:1>) * consts.Consts.grid_column_width))<EOL>nodes_with_classification.remove(successor_node)<EOL><DEDENT><DEDENT><DEDENT>return grid, last_row, last_col<EOL>
:param node_with_classification:
:param grid:
:param last_row:
:param last_col:
:param bpmn_graph:
:param nodes_with_classification:
:param enforced_row_num:
:return: