* @throws PersistitException
     */
    public boolean traverse(final Direction direction, final KeyFilter keyFilter, int minBytes)
            throws PersistitException {
        if (keyFilter == null) {
            return traverse(direction, true, minBytes);
        }

        if (direction == EQ) {
            return keyFilter.selected(_key) && traverse(direction, true, minBytes);
        }

        assertCorrectThread(true);
        if (_key.getEncodedSize() == 0) {
            if (direction == GT || direction == GTEQ) {
                _key.appendBefore();
            } else {
                _key.appendAfter();
            }
        }

        int totalVisited = 0;
        for (;;) {
            if (!keyFilter.next(_key, direction)) {
                _key.setEncodedSize(0);
                if (direction == LT || direction == LTEQ) {
                    _key.appendAfter();
                } else {
                    _key.appendBefore();
                }
                return false;
            }
            if (keyFilter.isKeyPrefixFilter()) {
                return traverse(direction, true, minBytes, keyFilter.getMinimumDepth(), keyFilter
                        .getKeyPrefixByteCount());
            }
            final boolean matched = traverse(direction, true, minBytes);
            totalVisited += _keysVisitedDuringTraverse;
            _keysVisitedDuringTraverse = totalVisited;
            if (!matched) {
                return false;
            }
            if (keyFilter.selected(_key)) {
                return true;
            }
        }
    }