public bool IterNext(ref TreeIter iter) { if ((sourceList == null) || (sourceList.Count == 0)) { return(false); } object node = NodeFromIter(iter); if (node == null) { return(false); } object lastNode; //Check for "Collection was modified" Exception try { lastNode = cachedEnumerator != null ? cachedEnumerator.Current : null; } catch (InvalidOperationException ex) { lastNode = null; } if (lastNode == node) { try { return(GetCacheNext(ref iter)); } catch (InvalidOperationException ex) { Console.WriteLine("Collection was changed"); } } cachedEnumerator = sourceList.GetEnumerator(); while (cachedEnumerator.MoveNext()) { if (node == cachedEnumerator.Current) { return(GetCacheNext(ref iter)); } } cachedEnumerator = null; return(false); }