class SaveEventQueue {

    public TransUnitSaveEvent getNextPendingForSaving(TransUnitId idToSave) {
        Optional<EventWrapper> pendingEvents =
                Iterables.tryFind(eventQueue, Predicates.and(
                        new FindByTransUnitIdPredicate(idToSave),
                        NotSavingPredicate.INSTANCE));
        if (!pendingEvents.isPresent()) {
            return null;
        } else {
            EventWrapper wrapper = pendingEvents.get();
            wrapper.setSaving(true);
            return wrapper.toEvent();
        }
    }

}