function isTapLeafInTree(tapLeaf, merkleRoot) {
  if (!merkleRoot) return true;
  const leafHash = tapleafHash({
    output: tapLeaf.script,
    version: tapLeaf.leafVersion,
  });
  const rootHash = rootHashFromPath(tapLeaf.controlBlock, leafHash);
  return tools.compare(rootHash, merkleRoot) === 0;
}
Checks if a TapLeafScript is present in a Merkle tree.
@param tapLeaf The TapLeafScript to check.
@param merkleRoot The Merkle root of the tree. If not provided, the function assumes the TapLeafScript is present.
@returns A boolean indicating whether the TapLeafScript is present in the tree.