guava/src/com/google/common/collect/Multimaps.java
public static <K, V> SetMultimap<K, V> filterEntries(
      SetMultimap<K, V> unfiltered, Predicate<? super Entry<K, V>> entryPredicate) {
    checkNotNull(entryPredicate);
    return (unfiltered instanceof FilteredSetMultimap)
        ? filterFiltered((FilteredSetMultimap<K, V>) unfiltered, entryPredicate)
        : new FilteredEntrySetMultimap<K, V>(checkNotNull(unfiltered), entryPredicate);
  }
public static <K, V> SetMultimap<K, V> filterEntries(
      SetMultimap<K, V> unfiltered, Predicate<? super Entry<K, V>> entryPredicate) {
    checkNotNull(entryPredicate);
    return (unfiltered instanceof FilteredSetMultimap)
        ? filterFiltered((FilteredSetMultimap<K, V>) unfiltered, entryPredicate)
        : new FilteredEntrySetMultimap<K, V>(checkNotNull(unfiltered), entryPredicate);
  }
Returns a multimap containing the mappings in {@code unfiltered} that satisfy a predicate. The
returned multimap is a live view of {@code unfiltered}; changes to one affect the other.

<p>The resulting multimap's views have iterators that don't support {@code remove()}, but all
other methods are supported by the multimap and its views. When adding a key/value pair that
doesn't satisfy the predicate, multimap's {@code put()}, {@code putAll()}, and {@code
replaceValues()} methods throw an {@link IllegalArgumentException}.

<p>When methods such as {@code removeAll()} and {@code clear()} are called on the filtered
multimap or its views, only mappings whose keys satisfy the filter will be removed from the
underlying multimap.

<p>The returned multimap isn't threadsafe or serializable, even if {@code unfiltered} is.

<p>Many of the filtered multimap's methods, such as {@code size()}, iterate across every
key/value mapping in the underlying multimap and determine which satisfy the filter. When a
live view is <i>not</i> needed, it may be faster to copy the filtered multimap and use the
copy.

<p><b>Warning:</b> {@code entryPredicate} must be <i>consistent with equals</i>, as documented
at {@link Predicate#apply}.

@since 14.0