PsiStatement (@NotNull Project project, @NotNull PsiElementFactory factory) { PsiExpression[] operands = myPolyadicExpression.getOperands(); int index = (int)StreamEx.of(operands).indexOf(o -> PsiTreeUtil.isAncestor(o, myExpression, false)) .orElseThrow(IllegalStateException::new); SurroundResult upstreamResult = myUpstream.surround(); PsiPolyadicExpression polyadicExpression = (PsiPolyadicExpression)Objects.requireNonNull(PsiUtil.skipParenthesizedExprDown(upstreamResult.getExpression())); PsiStatement statement = upstreamResult.getAnchor(); PsiExpression operand = polyadicExpression.getOperands()[index]; PsiExpression lOperands = SplitConditionUtil.getLOperands(polyadicExpression, Objects.requireNonNull( polyadicExpression.getTokenBeforeOperand(operand))); PsiExpression rOperands = getRightOperands(polyadicExpression, operand); if (statement instanceof PsiIfStatement) { return splitIf((PsiIfStatement)statement, polyadicExpression, lOperands, rOperands, project, factory); } assert statement instanceof PsiReturnStatement || statement instanceof PsiYieldStatement; return splitReturn(statement, polyadicExpression, lOperands, rOperands, project, factory); }