public Optional<Entry<K, V>> findFirstMatchingKey(final Txn<ByteBuffer> txn,
                                                      final KeyRange<K> keyRange,
                                                      final Predicate<K> keyPredicate) {

        try (final PooledByteBuffer startKeyPooledBuffer = getPooledKeyBuffer();
                final PooledByteBuffer stopKeyPooledBuffer = getPooledKeyBuffer()) {

            final KeyRange<ByteBuffer> serialisedKeyRange = serialiseKeyRange(startKeyPooledBuffer,
                    stopKeyPooledBuffer,
                    keyRange);

            return streamEntriesAsBytes(txn, serialisedKeyRange, entryStream ->
                    entryStream
                            .map(keyVal ->
                                    Map.entry(deserializeKey(keyVal.key()), keyVal.val()))
                            .filter(entry -> keyPredicate.test(entry.getKey()))
                            .map(entry -> Map.entry(
                                    entry.getKey(),
                                    deserializeValue(entry.getValue())))
                            .findFirst());
        }
    }
Find the first entry matching the supplied key predicate in the supplied key range.
Not very efficient as it will scan over all entries in the range (de-serialising
each key as it goes) till it finds a match. Values only de-serialised if the keyPredicate
is matched.
stroom-lmdb/src/main/java/stroom/lmdb/AbstractLmdbDb.java