code: function reverse() {
    const nodes = [];
    const cnodes = [];
    const mapping = {};
    const root = new Node(undefined, undefined);
    this.each((node) => {
      nodes.push(node);
      const cnode = new Node(node.id, node.data);
      cnodes.push(cnode);
      mapping[cnode.id] = cnode;
      if (!node.children.length) {
        root.children.push(cnode);
      }
    });
    cnodes.forEach((cnode, i) => {
      const node = nodes[i];
      node.children.map((c, j) => {
        const cc = mapping[c.id];
        cc.children.push(cnode);
        cc._childLinkData.push(node._childLinkData[j]);
      });
    });
  
    return root.children.length > 1 ? root : root.children[0];
  }
docs: Reverse