private static Set<Class<?>> collectHierarchyClasses(Collection<Class<?>> classes) {
        Set<Class<?>> resultSet = new HashSet<>();
        for (Class<?> cls : classes) {
            Class<?> curCls = cls;
            while (curCls != null) {
                resultSet.add(curCls);
                curCls = curCls.getSuperclass();
            }
        }
        return resultSet;
    }