public override bool Equals(object obj) { BinomialTree <TKey, TValue> other; if ((other = obj as BinomialTree <TKey, TValue>) == null) { return(false); } if (!RootValue.Equals(other.RootValue) || (RootKey.CompareTo(other.RootKey) != 0) || (subTrees.Count != other.subTrees.Count)) { return(false); } foreach (BinomialTree <TKey, TValue> subTree in subTrees) { if (!other.subTrees.Contains(subTree)) { return(false); } } return(true); }