code: public static <R> Set<R> filterAndListKeys(Iterator<R> keys, KeyFilter<R> filter) {
          Set<R> ret = new HashSet<R>();
          while (keys.hasNext()) {
              R key = keys.next();
              R filtered = filter.filter(key);
              if (filtered != null) {
                  ret.add(filtered);
              }
          }
          return ret;
      }
docs: Filters keys based on the KeyFilter
  passed as the argument.
  
  @param filter KeyFilter
  @param <R>    Type
  @return Set of filtered keys