nodes: 0, module; 1, function_definition; 2, function_name:_concat_records; 3, parameters; 4, block; 5, identifier:items_by_key; 6, identifier:input_order; 7, expression_statement; 8, expression_statement; 9, for_statement; 10, expression_statement; 11, expression_statement; 12, if_statement; 13, return_statement; 14, comment:"""Concatenate records into a single key to avoid merging.
  
      Handles heterogeneous records that will then be sorted out in
      the processing fuction.
      """; 15, assignment; 16, tuple_pattern; 17, call; 18, block; 19, assignment; 20, assignment; 21, comparison_operator:len(all_records) > 1; 22, block; 23, expression_list; 24, identifier:all_records; 25, list; 26, identifier:k; 27, identifier:t; 28, attribute; 29, argument_list; 30, if_statement; 31, identifier:out_items_by_key; 32, call; 33, identifier:out_input_order; 34, call; 35, call; 36, integer:1; 37, expression_statement; 38, expression_statement; 39, for_statement; 40, expression_statement; 41, identifier:out_items_by_key; 42, identifier:out_input_order; 43, identifier:input_order; 44, identifier:items; 45, comparison_operator:t == "record"; 46, block; 47, attribute; 48, argument_list; 49, attribute; 50, argument_list; 51, identifier:len; 52, argument_list; 53, assignment; 54, assignment; 55, identifier:k; 56, subscript; 57, block; 58, assignment; 59, identifier:t; 60, string:"record"; 61, expression_statement; 62, identifier:utils; 63, identifier:deepish_copy; 64, identifier:items_by_key; 65, identifier:utils; 66, identifier:deepish_copy; 67, identifier:input_order; 68, identifier:all_records; 69, identifier:final_k; 70, subscript; 71, identifier:final_v; 72, subscript; 73, identifier:all_records; 74, slice; 75, expression_statement; 76, delete_statement; 77, delete_statement; 78, subscript; 79, identifier:final_v; 80, call; 81, identifier:all_records; 82, integer:0; 83, identifier:items_by_key; 84, identifier:final_k; 85, integer:1; 86, augmented_assignment; 87, subscript; 88, subscript; 89, identifier:out_items_by_key; 90, identifier:final_k; 91, attribute; 92, argument_list; 93, identifier:final_v; 94, subscript; 95, identifier:out_items_by_key; 96, identifier:k; 97, identifier:out_input_order; 98, identifier:k; 99, identifier:all_records; 100, identifier:append; 101, identifier:k; 102, identifier:items_by_key; 103, identifier:k
code: def _concat_records(items_by_key, input_order):
      """Concatenate records into a single key to avoid merging.
  
      Handles heterogeneous records that will then be sorted out in
      the processing fuction.
      """
      all_records = []
      for (k, t) in input_order.items():
          if t == "record":
              all_records.append(k)
      out_items_by_key = utils.deepish_copy(items_by_key)
      out_input_order = utils.deepish_copy(input_order)
      if len(all_records) > 1:
          final_k = all_records[0]
          final_v = items_by_key[final_k]
          for k in all_records[1:]:
              final_v += items_by_key[k]
              del out_items_by_key[k]
              del out_input_order[k]
          out_items_by_key[final_k] = final_v
      return out_items_by_key, out_input_order