PsiExpression (@NotNull Check c1, @NotNull Check c2, @NotNull String operator) { PsiExpression cond1 = c1.myCondition; PsiExpression cond2 = c2.myCondition; PsiElementFactory factory = PsiElementFactory.getInstance(cond1.getProject()); return factory.createExpressionFromText(ParenthesesUtils.getText(cond1, ParenthesesUtils.OR_PRECEDENCE) + operator + ParenthesesUtils.getText(cond2, ParenthesesUtils.OR_PRECEDENCE), cond1); }