function toHashTree(scriptTree) {
  if (isTapleaf(scriptTree)) return { hash: tapleafHash(scriptTree) };
  const hashes = [toHashTree(scriptTree[0]), toHashTree(scriptTree[1])];
  // hashes.sort((a, b) => a.hash.compare(b.hash));
  hashes.sort((a, b) => tools.compare(a.hash, b.hash));
  const [left, right] = hashes;
  return {
    hash: tapBranchHash(left.hash, right.hash),
    left,
    right,
  };
}
Build a hash tree of merkle nodes from the scripts binary tree.
@param scriptTree - the tree of scripts to pairwise hash.