docs: def merge_nodes(nodes, plane, page_stat, merge_indices):
      """
      Merges overlapping nodes
      """
      # Merge inner boxes to the best outer box
      # nodes.sort(key=Node.area)
      to_be_removed = set()
      for inner_idx in range(len(nodes)):
          inner = nodes[inner_idx]
          outers = []
          outers_indices = []
          for outer_idx in range(len(nodes)):
              outer = nodes[outer_idx]
              if outer is inner or outer in to_be_removed:
                  continue
              if intersect(outer.bbox, inner.bbox):
                  outers.append(outer)
                  outers_indices.append(outer_idx)
          if not outers:
              continue
          # Best is defined as min L1 distance to outer center
          best_outer = min(
              outers, key=lambda outer: l1(center(outer.bbox), center(inner.bbox))
          )
          best_outer_idx = outers_indices[outers.index(best_outer)]
          to_be_removed.add(inner)
          best_outer.merge(inner)
          for cid_iter in range(len(merge_indices)):
              if merge_indices[cid_iter] == merge_indices[inner_idx]:
                  merge_indices[cid_iter] = merge_indices[best_outer_idx]
      return nodes, merge_indices