code: public static <T extends SoyNode> T cloneWithNewIds(T origNode, IdGenerator nodeIdGen) {
  
      // Clone the node.
      @SuppressWarnings("unchecked")
      T clone = (T) origNode.copy(new CopyState());
  
      // Generate new ids.
      (new GenNewIdsVisitor(nodeIdGen)).exec(clone);
  
      return clone;
    }
docs: Clones the given node and then generates and sets new ids on all the cloned nodes (by default,
  SoyNode.copy(copyState) creates cloned nodes with the same ids as the original nodes).
  
  <p>This function will use the original Soy tree's node id generator to generate the new node
  ids for the cloned nodes. Thus, the original node to be cloned must be part of a full Soy tree.
  However, this does not mean that the cloned node will become part of the original tree (unless
  it is manually attached later). The cloned node will be an independent subtree with parent set
  to null.
  
  @param <T> The type of the node being cloned.
  @param origNode The original node to be cloned. This node must be part of a full Soy tree,
  because the generator for the new node ids will be retrieved from the root (SoyFileSetNode)
  of the tree.
  @param nodeIdGen The ID generator used for the tree.
  @return The cloned node, with all new ids for its subtree.