code: private boolean shouldProtect(Expression operand, OperandPosition operandPosition) {
      if (operand instanceof Operation) {
        Operation operation = (Operation) operand;
        return operation.precedence() < this.precedence()
            || (operation.precedence() == this.precedence()
                && operandPosition.shouldParenthesize(operation.associativity()));
      } else if (operand instanceof Leaf) {
        // JsExprs have precedence info, but not associativity. So at least check the precedence.
        JsExpr expr = ((Leaf) operand).value();
        return expr.getPrecedence() < this.precedence();
      } else {
        return false;
      }
    }
docs: An operand needs to be protected with parens if
  
  <ul>
  <li>its {@link #precedence} is lower than the operator's precedence, or
  <li>its precedence is the same as the operator's, it is {@link Associativity#LEFT left
  associative}, and it appears to the right of the operator, or
  <li>its precedence is the same as the operator's, it is {@link Associativity#RIGHT right
  associative}, and it appears to the left of the operator.
  </ul>