internal BaseRecord IncrementalSearch(BaseRecord tn, bool first, bool forward, bool wrapAround, Predicate <BaseRecord> searchFunc) { using (var itr = new RecursiveRecordIterator(tn, forward)) { BaseRecord startNode = null; Debug.Assert(tn.Equals(itr.Current)); bool keep = first; do { do { tn = itr.Current; if (keep && searchFunc(tn)) { return(tn); } keep = true; if (startNode == null) { startNode = tn; } else if (startNode.Equals(tn)) { return(null); } } while (itr.MoveNext()); if (!wrapAround) { break; } itr.Push(PluginList.All.Records[0] as BaseRecord); itr.Reset(); wrapAround = false;// multipass protection } while (itr.MoveNext()); } return(null); }