Correct me if I’m wrong but it seems that rbtree doesn’t backtrack?
I do something a bit like this:
foldl([K,V,T0,T]>>rb_insert(T0,K,V,T), Keys, Values, EmptyTree, FullTree)
and I find that EmptyTree is modified!
I make note of this because the documentation doesn’t say that anywhere so far as I can see: rbtrees.pl -- Red black trees.