public static <T> Collection<T> filter(Collection<?> collection, Class<T> lowerBound) {
        List<T> result = new ArrayList<>();
        for (Object element : collection) {
            if (lowerBound.isInstance(element)) {
                result.add(lowerBound.cast(element));
            }
        }
        return result;
    }
Returns the subset of elements from the given collection that can be cast to the reference
type, defined by the given Class object.
vespajlib/src/main/java/com/yahoo/collections/CollectionUtil.java