private static bool EndlessCircleWasPassed(MultiDictionary <int, NodeWithMinimumStackHeightAfterIt> potentialCircleStartsWithMinStack, Node <A, S> currentNode) { var potentialCircleStartsWithSameState = potentialCircleStartsWithMinStack.ValuesOfKey(currentNode.Config.State.Id); var potentialCirlceStartsWithLessOrEqualStackHeight = potentialCircleStartsWithSameState.Where(cirlceStart => cirlceStart.Node.Config.Stack.StackSymbols.Count() <= currentNode.Config.Stack.StackSymbols.Count()); return(potentialCirlceStartsWithLessOrEqualStackHeight.Any(circleStartNodeWithMinStack => { var circleStartNode = circleStartNodeWithMinStack.Node; var numberOfMaxPoppedStackSymbols = circleStartNode.Config.Stack.StackSymbols.Count() - circleStartNodeWithMinStack.MinimumStackHeightAfterIt + 1; return circleStartNode.Config.Stack.HasSameTopMostSymbolsLike(currentNode.Config.Stack, numberOfMaxPoppedStackSymbols); })); }