private static void Scan(BMultiMap <int, Pair <ILNode, int> > locations, int charIndex, IndexRange targetRange, int scanDirection, int iterations, Dictionary <Pair <ILNode, IndexRange>, float> results) { for (int i = locations.FindLowerBound(charIndex); iterations > 0; iterations--, i += scanDirection) { var pair = locations.TryGet(i, out bool fail); if (!fail) { var nodeWithRange = Pair.Create(pair.Value.Item1, RangeOf(pair)); float score = GetMismatchScore(pair, targetRange); if (score < results.TryGetValue(nodeWithRange, float.MaxValue)) { results[nodeWithRange] = score; } } } }