Verify a merkle path.  The given path is the path from two leaf nodes to the root itself.

    merkle_root_hex is a little-endian, hex-encoded hash.
    serialized_path is the serialized merkle path
    path_hex is a list of little-endian, hex-encoded hashes.

    Return True if the path is consistent with the merkle root.
    Return False if not.

def verify_merkle_path(merkle_root_hex, serialized_path, leaf_hash_hex, hash_function=bin_double_sha256):
    """
    Verify a merkle path.  The given path is the path from two leaf nodes to the root itself.

    merkle_root_hex is a little-endian, hex-encoded hash.
    serialized_path is the serialized merkle path
    path_hex is a list of little-endian, hex-encoded hashes.

    Return True if the path is consistent with the merkle root.
    Return False if not.
    """
    
    merkle_root = hex_to_bin_reversed(merkle_root_hex)
    leaf_hash = hex_to_bin_reversed(leaf_hash_hex)

    path = MerkleTree.path_deserialize(serialized_path)
    path = [{'order': p['order'], 'hash': hex_to_bin_reversed(p['hash'])} for p in path]

    if len(path) == 0:
        raise ValueError("Empty path")

    cur_hash = leaf_hash
    for i in range(0, len(path)):
        if path[i]['order'] == 'l':
            # left sibling
            cur_hash = hash_function(path[i]['hash'] + cur_hash)
        elif path[i]['order'] == 'r':
            # right sibling
            cur_hash = hash_function(cur_hash + path[i]['hash'])
        elif path[i]['order'] == 'm':
            # merkle root
            assert len(path) == 1
            return cur_hash == path[i]['hash']

    return cur_hash == merkle_root