boolean (PsiElement element) { if (!(element instanceof PsiExpressionStatement statement)) { return false; } final PsiExpression expression = statement.getExpression(); final PsiElement parent = expression.getParent(); if (!(parent instanceof PsiExpressionStatement)) { return false; } final PsiType type = expression.getType(); if (!PsiTypes.booleanType().equals(type)) { return false; } PsiMethod containingMethod = PsiTreeUtil.getParentOfType(expression, PsiMethod.class); while (containingMethod != null) { if (TestUtils.isJUnitTestMethod(containingMethod)) { return true; } containingMethod = PsiTreeUtil.getParentOfType(containingMethod, PsiMethod.class); } return false; }