PsiType (@NotNull PsiMethodCallExpression expression) { PsiExpression highestPredicate = expression; int max = 100; int currentLevel = 0; while (currentLevel <= max) { currentLevel++; //example: Predicate.isEqual("1").or(...) or Predicate.isEqual("1").and(...) or Predicate.isEqual("1").negate() final PsiMethodCallExpression call = ExpressionUtils.getCallForQualifier(highestPredicate); if (PREDICATE_OR_AND_NEGATE.matches(call)) { highestPredicate = call; continue; } //example: Predicate.not(Predicate.isEqual("1")) or predicate.or(Predicate.isEqual("1")) or predicate.and(Predicate.isEqual("1")) final PsiElement parent = PsiUtil.skipParenthesizedExprUp(highestPredicate.getParent()); if (parent instanceof PsiExpressionList && parent.getParent() instanceof PsiExpression psiExpressionNextParent) { if (PREDICATE_NOT_OR_AND.matches(psiExpressionNextParent)) { highestPredicate = psiExpressionNextParent; continue; } } break; } return findPsiTypeForPredicate(highestPredicate); }