public static <T> Predicate<T> distinctByKey( Function<? super T, Object> keyExtractor )
    {
        final Map<Object, Boolean> seen = new ConcurrentHashMap<>();
        return t -> seen.putIfAbsent( keyExtractor.apply( t ), Boolean.TRUE ) == null;
    }
Returns a stateful stream filter that, once applied to a stream, returns a stream consisting
of the distinct elements (according to the specified key).
<p>
The implementation of {@link Stream#distinct()} can be used to return a stream that has distinct
elements, based on the implementation of {@link Object#equals(Object)}. That implementation does
not allow to filter a stream based on one property of each object. The implementation of provided
by this method does.

@param keyExtractor A function to extract the desired key from the stream objects (cannot be null).
@param <T>          Stream element type.
@return A filter
@see <a href="https://stackoverflow.com/questions/27870136/java-lambda-stream-distinct-on-arbitrary-key">Stack Overflow: Java Lambda Stream Distinct() on arbitrary key?</a>
xmppserver/src/main/java/org/jivesoftware/util/CollectionUtils.java