/** Do a structural comparison */ private LEG structural_cmp(SafraTreeNode other) { LEG cmp = CMP(_final_flag ? 1 : 0, other._final_flag ? 1 : 0); if (cmp != LEG.EQUAL) { return(cmp); } cmp = CMP(_childCount, other._childCount); if (cmp != LEG.EQUAL) { return(cmp); } cmp = CMP(_labeling, other._labeling); if (cmp != LEG.EQUAL) { return(cmp); } // if we are here, this and other have the same number of children if (_childCount > 0) { SafraTreeNode this_child = this._oldestChild; SafraTreeNode other_child = other._oldestChild; do { cmp = this_child.structural_cmp(other_child); if (cmp != LEG.EQUAL) { return(cmp); } this_child = this_child._youngerBrother; other_child = other_child._youngerBrother; } while (this_child != null && other_child != null); // assert that there was really the same number of children System.Diagnostics.Debug.Assert(this_child == null && other_child == null); } // when we are here, all children were equal return(LEG.EQUAL); }