let for_all s ~f =
let rec test_range n1 n2 =
if n1 = n2 then f n1 else
f n1 && test_range (n1 + 1) n2 in
let rec test_set s =
if is_empty s then true else
let n1, n2 = root s in
test_range n1 n2 &&
test_set (left_branch s) &&
test_set (right_branch s) in
test_set s