function instertLeavesInTree(leaves) {
  let tree;
  for (const leaf of leaves) {
    tree = instertLeafInTree(leaf, tree);
    if (!tree) throw new Error(`No room left to insert tapleaf in tree`);
  }
  return tree;
}
Inserts the tapleaves into the taproot tree.
@param leaves The tapleaves to insert.
@returns The taproot tree.
@throws Throws an error if there is no room left to insert a tapleaf in the tree.