function tapTreeFromList(leaves = []) {
  if (leaves.length === 1 && leaves[0].depth === 0)
    return {
      output: leaves[0].script,
      version: leaves[0].leafVersion,
    };
  return instertLeavesInTree(leaves);
}
Convert a BIP371 TapLeaf list to a TapTree (binary).
@param leaves a list of tapleaves where each element of the list is (according to BIP371):
One or more tuples representing the depth, leaf version, and script for a leaf in the Taproot tree,
allowing the entire tree to be reconstructed. The tuples must be in depth first search order so that
the tree is correctly reconstructed.
@returns the corresponding taptree, or throws an exception if the tree cannot be reconstructed