private void MergeWithRoot(IUnionFind <IData> root) { if (Depth < root.Depth) { Root = root; } else if (Depth > root.Depth) { root.MergeWith(this); } else if (root != this) { Depth += 1; root.MergeWith(this); } }