public static Stream<Class<?>> traverseAncestors(Class<?> clazz) {
        if (clazz.getSuperclass() == null) { // We have reached Object.class
            return Stream.of(clazz);
        } else {
            return Stream.concat(
                Stream.of(clazz),
                Stream.concat(
                    traverseAncestors(clazz.getSuperclass()),
                    Stream.of(clazz.getInterfaces())
                )
            ).distinct();
        }
    }
Some common utility methods for analyzing classes with reflection.

@author Emil Forslund
@since 1.0.0
common-parent/injector/src/main/java/com/speedment/common/injector/internal/util/ReflectionUtil.java