PsiMethodCallExpression (@Nullable PsiElement element, @NotNull PsiMethod method) { PsiMethodCallExpression tailCall = null; if (element instanceof PsiReturnStatement returnStatement) { PsiExpression returnValue = PsiUtil.skipParenthesizedExprDown(returnStatement.getReturnValue()); while (returnValue instanceof PsiPolyadicExpression polyadic) { returnValue = null; IElementType tokenType = polyadic.getOperationTokenType(); if (tokenType == JavaTokenType.ANDAND || tokenType == JavaTokenType.OROR) { PsiExpression[] operands = polyadic.getOperands(); if (operands.length >= 2) { returnValue = PsiUtil.skipParenthesizedExprDown(ArrayUtil.getLastElement(operands)); } } } tailCall = ObjectUtils.tryCast(returnValue, PsiMethodCallExpression.class); } else if (element instanceof PsiExpressionStatement && (ControlFlowUtils.blockCompletesWithStatement(Objects.requireNonNull(method.getBody()), (PsiStatement)element) || isBeforeVoidReturn(element, method))) { final PsiExpression expression = ((PsiExpressionStatement)element).getExpression(); tailCall = ObjectUtils.tryCast(expression, PsiMethodCallExpression.class); } if (tailCall == null) return null; final JavaResolveResult resolveResult = tailCall.resolveMethodGenerics(); return resolveResult.isValidResult() && method.equals(resolveResult.getElement()) ? tailCall : null; }