Implemented an invariant function to enforce the DIET invariants (in addition to the AVL invariants).