PsiMethodCallExpression (PsiMethodCallExpression expression) { PsiMethodCallExpression chain = expression; while (true) { final PsiMethodCallExpression current = PsiTreeUtil.getParentOfType(chain, PsiMethodCallExpression.class); if (current != null && current.getMethodExpression().getQualifierExpression() == chain) { final PsiMethod method = current.resolveMethod(); if (method == null) { return chain; } if (FLUENT_ITERABLE_STOP_METHODS.contains(method.getName())) { return null; } final PsiClass containingClass = method.getContainingClass(); if (containingClass == null || !(GuavaFluentIterableConversionRule.FLUENT_ITERABLE.equals(containingClass.getQualifiedName()) || GuavaOptionalConversionRule.GUAVA_OPTIONAL.equals(containingClass.getQualifiedName()))) { return chain; } final PsiType returnType = method.getReturnType(); final PsiClass returnClass = PsiTypesUtil.getPsiClass(returnType); if (returnClass == null || !(GuavaFluentIterableConversionRule.FLUENT_ITERABLE.equals(returnClass.getQualifiedName()) || GuavaOptionalConversionRule.GUAVA_OPTIONAL.equals(returnClass.getQualifiedName()))) { return chain; } if (GuavaTypeConversionDescriptor.isIterable(current)) { return chain; } } else { return chain; } chain = current; } }