ForEachCollectionTraversal (@NotNull PsiForeachStatement loop) { PsiExpression collection = extractCollectionExpression(loop.getIteratedValue()); if (collection == null) return null; PsiType collectionElement = PsiUtil.substituteTypeParameter(collection.getType(), JAVA_UTIL_COLLECTION, 0, false); if (collectionElement == null) return null; PsiParameter parameter = loop.getIterationParameter(); if (!parameter.getType().equals(collectionElement)) return null; return new ForEachCollectionTraversal(collection, parameter); }