void (@NotNull PsiElement element) { final PsiJavaToken token = (PsiJavaToken)element; final PsiIfStatement parentStatement = (PsiIfStatement)token.getParent(); if (parentStatement == null) return; final PsiStatement parentThenBranch = ControlFlowUtils.stripBraces(parentStatement.getThenBranch()); if (!(parentThenBranch instanceof PsiIfStatement childStatement)) return; final PsiExpression childCondition = childStatement.getCondition(); if (childCondition == null) return; final PsiStatement childThenBranch = childStatement.getThenBranch(); if (childThenBranch == null) return; final PsiExpression parentCondition = parentStatement.getCondition(); if (parentCondition == null) return; CommentTracker ct = new CommentTracker(); final String childConditionText = ParenthesesUtils.getText(ct.markUnchanged(childCondition), ParenthesesUtils.OR_PRECEDENCE); final String parentConditionText = ParenthesesUtils.getText(ct.markUnchanged(parentCondition), ParenthesesUtils.OR_PRECEDENCE); @NonNls final String statement = "if(" + parentConditionText + "&&" + childConditionText + ')' + ct.text(childThenBranch); ct.replaceAndRestoreComments(parentStatement, statement); }