public List<Object> getElementsMatching(Predicate matchingPredicate, Predicate endPredicate) {
    getInitializationLock().readLock().lock();
    try {
      if (getPartitionedRegion().isDestroyed()) {
        throw new BucketRegionQueueUnavailableException();
      }
      List<Object> elementsMatching = new ArrayList<>();
      for (final Object key : eventSeqNumDeque) {
        Object object = optimalGet(key);
        if (object == null) {
          continue;
        }

        if (matchingPredicate.test(object)) {
          elementsMatching.add(object);
          eventSeqNumDeque.remove(key);
          if (endPredicate.test(object)) {
            break;
          }
        }
      }
      return elementsMatching;
    } finally {
      getInitializationLock().readLock().unlock();
    }
  }
This method returns a list of objects that fulfill the matchingPredicate.
If a matching object also fulfills the endPredicate then the method
stops looking for more matching objects.
geode-core/src/main/java/org/apache/geode/internal/cache/BucketRegionQueue.java