let rec from 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 < v1 then make_tree (from s0 ~n) v s1 else
if n > v2 then from s1 ~n else
make_tree empty (n, v2) s1