let rec split x = function
Empty ->
(Empty, false, Empty)
| Node(l, v, r, _) ->
let c = Ord.compare x v in
if c = 0 then (l, true, r)
else if c < 0 then
let (ll, pres, rl) = split x l in (ll, pres, join rl v r)
else
let (lr, pres, rr) = split x r in (join l v lr, pres, rr)