public static <K, V> Map<K, V> filterNullValues(Map<K, V> map) {
    map.entrySet().removeIf(next -> next.getValue() == null);
    return map;
  }
(Partial) replacement for Arrays.copyOfRange, which is only available in JDK6.
spock-core/src/main/java/org/spockframework/util/CollectionUtil.java