added some unit tests;
made improvements to mechanisms for keeping one or two trees in a self-consistent state after add, remove, or parent change operations