let handle_rightmost_itv
      ~extend_right
      same_values ei new_vv ((_,ei1),vv1) acc =
    if Int.gt ei1 ei
    then (* Part of the previous binding remains
            on the right-hand-side *)

      if extend_right && same_values vv1 new_vv
      then (* same value -> merge keys *)
        acc,ei1
      else add (Int.succ ei, ei1) vv1 acc,ei
    else enlarge_to_right ~extend_right same_values ei new_vv acc