boolean (@Nullable final PsiExpression expression) { if (expression == null) return false; if (expression instanceof PsiLiteralExpression) return true; if (expression instanceof PsiPolyadicExpression) { Stack<PsiExpression> stack = new Stack<>(); stack.add(expression); while (!stack.isEmpty()) { PsiExpression psiExpression = stack.pop(); if (psiExpression instanceof PsiPolyadicExpression binaryExpression) { for (PsiExpression op : binaryExpression.getOperands()) { stack.push(op); } } else if (!(psiExpression instanceof PsiLiteralExpression)) { return false; } } return true; } return false; }