let add_range s n1 n2 =
if n1 > n2 then invalid_arg (Printf.sprintf "ISet.add_range - %d > %d" n1 n2) else
let n1, l =
if n1 = min_int then n1, empty else
let l = until s ~n:(n1 - 1) in
if is_empty l then n1, empty else
let (v1, v2), l' = split_rightmost l in
if v2 + 1 = n1 then v1, l' else n1, l in
let n2, r =
if n2 = max_int then n2, empty else
let r = from s ~n:(n2 + 1) in
if is_empty r then n2, empty else
let (v1, v2), r' = split_leftmost r in
if n2 + 1 = v1 then v2, r' else n2, r in
make_tree l (n1, n2) r