class MoreClasses {

	public static Set<Class> getInheritedClasses(Class clazz) {
		Set<Class> inheritedClasses = Sets.newHashSet();

		// add super class, and add recursively their inherited classes
		Class superClass = clazz.getSuperclass();
		if (superClass != null) {
			inheritedClasses.add(superClass);
			inheritedClasses.addAll(getInheritedClasses(superClass));
		}

		// add all interfaces, and recursively add their inherited classes
		Class[] interfaces = clazz.getInterfaces();
		for (Class anInterface : interfaces) {
			inheritedClasses.add(anInterface);
			inheritedClasses.addAll(getInheritedClasses(anInterface));
		}

		return inheritedClasses;
	}

}

class MoreClassesTest {

	@Test
	public void should_find_inherited_super_classes() {

		assertThat(getInheritedClasses(B.class)).containsOnly(A.class, Object.class);
		assertThat(getInheritedClasses(C.class)).containsOnly(B.class, A.class, Object.class);
	}

}