List<NavigatableMessageElement> (@NotNull String groupName) { synchronized (myLock) { List<NavigatableMessageElement> elements = myGroupNameToMessagesMap.get(groupName); if (elements == null) return Collections.emptyList(); List<NavigatableMessageElement> removed = new ArrayList<>(elements); elements.clear(); return removed; } }