let rec until s ~n =
if is_empty s then empty else
let (v1, v2) as v = root s in
let s0 = left_branch s in
let s1 = right_branch s in
if n > v2 then make_tree s0 v (until s1 ~n) else
if n < v1 then until s0 ~n else
make_tree s0 (v1, n) empty