code: private Node tryFoldHook(Node n) {
      checkState(n.isHook(), n);
      Node parent = n.getParent();
      checkNotNull(parent);
      Node cond = n.getFirstChild();
      Node thenBody = cond.getNext();
      Node elseBody = thenBody.getNext();
  
      TernaryValue condValue = NodeUtil.getImpureBooleanValue(cond);
      if (condValue == TernaryValue.UNKNOWN) {
        // If the result nodes are equivalent, then one of the nodes can be
        // removed and it doesn't matter which.
        if (!areNodesEqualForInlining(thenBody, elseBody)) {
          return n;  // We can't remove branches otherwise!
        }
      }
  
      // Transform "(a = 2) ? x =2 : y" into "a=2,x=2"
      Node branchToKeep;
      Node branchToRemove;
      if (condValue.toBoolean(true)) {
        branchToKeep = thenBody;
        branchToRemove = elseBody;
      } else {
        branchToKeep = elseBody;
        branchToRemove = thenBody;
      }
  
      Node replacement;
      boolean condHasSideEffects = mayHaveSideEffects(cond);
      // Must detach after checking for side effects, to ensure that the parents
      // of nodes are set correctly.
      n.detachChildren();
      if (condHasSideEffects) {
        replacement = IR.comma(cond, branchToKeep).srcref(n);
      } else {
        replacement = branchToKeep;
        markFunctionsDeleted(cond);
      }
  
      parent.replaceChild(n, replacement);
      reportChangeToEnclosingScope(replacement);
      markFunctionsDeleted(branchToRemove);
      return replacement;
    }
docs: Try folding HOOK (?:) if the condition results of the condition is known.
  @return the replacement node, if changed, or the original if not