PsiExpression (@Nullable PsiExpression methodType) { methodType = findDefinition(methodType); int preventEndlessLoop = 5; while (METHOD_TYPE_WITH_METHOD_TYPE_MATCHER.matches(methodType)) { if (--preventEndlessLoop == 0) { return null; } methodType = PsiUtil.skipParenthesizedExprDown(methodType); if (!(methodType instanceof PsiMethodCallExpression call)) { return null; } final PsiExpression[] expressions = call.getArgumentList().getExpressions(); if (expressions.length != 2) { return null; } methodType = findDefinition(expressions[1]); } return METHOD_TYPE_MATCHER.matches(methodType) ? methodType : null; }