code: private Expression extractSideEffects(Expression expr) {
      if (expr.getConstantValue() instanceof Boolean) {
        return null;
      }
      switch (expr.getKind()) {
        case INFIX_EXPRESSION:
          {
            List<Expression> operands = ((InfixExpression) expr).getOperands();
            Expression lastOperand = operands.remove(operands.size() - 1);
            lastOperand = extractSideEffects(lastOperand);
            if (lastOperand != null) {
              operands.add(lastOperand);
            }
            if (operands.size() == 1) {
              return operands.remove(0);
            }
            return TreeUtil.remove(expr);
          }
        case PARENTHESIZED_EXPRESSION:
          {
            Expression sideEffects = extractSideEffects(
                ((ParenthesizedExpression) expr).getExpression());
            if (sideEffects != null) {
              return ParenthesizedExpression.parenthesize(sideEffects);
            }
            return null;
          }
        default:
          return null;
      }
    }
docs: Returns an expression containing the side effects of the given expression.
  The evaluated result of the expression may differ from the original.