class CollectionUtilities {

    public static Set<Class<?>> determineClassTypesInCollection(Set<Class<?>> addToSet, Collection<?> items)
    {
        Set<Class<?>> types = addToSet;
        if (types == null)
        {
            types = New.set();
        }

        Class<?> lastClass = null;
        for (Object item : items)
        {
            Class<?> currentClass = item.getClass();
            if (!Utilities.sameInstance(lastClass, currentClass))
            {
                types.add(currentClass);
                lastClass = currentClass;
            }
        }

        return types;
    }

    private  CollectionUtilities();

}