private static Boolean FilterOutThreeOrMoreConsecutiveIdenticalOperationKinds( IDictionary <Int32, Tuple <Int32, Object> > testVariableIndexToLevelDictionary) { var testVariableIndices = testVariableIndexToLevelDictionary.Keys; var numberOfTestVariables = testVariableIndices.Count; var sortedTestVariableIndices = new Int32[numberOfTestVariables]; testVariableIndices.CopyTo(sortedTestVariableIndices, 0); Array.Sort(sortedTestVariableIndices); if (1 >= numberOfTestVariables) { return(true); } var preceedingTestVariableIndexAndConsecutiveCount = Tuple.Create(sortedTestVariableIndices.First(), 1); foreach (var index in Enumerable.Range(1, numberOfTestVariables - 1)) { var testVariableIndex = sortedTestVariableIndices[index]; var preceedingTestVariableIndex = preceedingTestVariableIndexAndConsecutiveCount.Item1; if (1 + preceedingTestVariableIndex == testVariableIndex && testVariableIndexToLevelDictionary[preceedingTestVariableIndex].Item1 == testVariableIndexToLevelDictionary[testVariableIndex].Item1) { var consecutiveCount = preceedingTestVariableIndexAndConsecutiveCount.Item2; if (2 == consecutiveCount) { return(false); } preceedingTestVariableIndexAndConsecutiveCount = Tuple.Create(testVariableIndex, 1 + consecutiveCount); } else { preceedingTestVariableIndexAndConsecutiveCount = Tuple.Create(testVariableIndex, 1); } } return(true); }