code: static TernaryValue getImpureBooleanValue(Node n) {
      switch (n.getToken()) {
        case ASSIGN:
        case COMMA:
          // For ASSIGN and COMMA the value is the value of the RHS.
          return getImpureBooleanValue(n.getLastChild());
        case NOT:
          TernaryValue value = getImpureBooleanValue(n.getLastChild());
          return value.not();
        case AND: {
          TernaryValue lhs = getImpureBooleanValue(n.getFirstChild());
          TernaryValue rhs = getImpureBooleanValue(n.getLastChild());
          return lhs.and(rhs);
        }
        case OR:  {
          TernaryValue lhs = getImpureBooleanValue(n.getFirstChild());
          TernaryValue rhs = getImpureBooleanValue(n.getLastChild());
          return lhs.or(rhs);
        }
        case HOOK:  {
          TernaryValue trueValue = getImpureBooleanValue(
              n.getSecondChild());
          TernaryValue falseValue = getImpureBooleanValue(n.getLastChild());
          if (trueValue.equals(falseValue)) {
            return trueValue;
          } else {
            return TernaryValue.UNKNOWN;
          }
        }
        case NEW:
        case ARRAYLIT:
        case OBJECTLIT:
          // ignoring side-effects
          return TernaryValue.TRUE;
  
        case VOID:
          return TernaryValue.FALSE;
  
        default:
          return getPureBooleanValue(n);
      }
    }
docs: Gets the boolean value of a node that represents a expression. This method
  effectively emulates the <code>Boolean()</code> JavaScript cast function.
  Note: unlike getPureBooleanValue this function does not return UNKNOWN
  for expressions with side-effects.