static Set<Class<?>> getAllSupertypes(Class<?> type) {
        if (type == null) {
            return Collections.emptySet();
        }

        ImmutableSet.Builder<Class<?>> result = ImmutableSet.<Class<?>>builder()
                .add(type)
                .addAll(getAllSupertypes(type.getSuperclass()));
        for (Class<?> c : type.getInterfaces()) {
            result.addAll(getAllSupertypes(c));
        }
        return result.build();
    }
@Test
    public void getAllSupertypes() {
        assertThat(ReflectionUtils.getAllSupertypes(Child.class)).containsOnly(
                Child.class, ChildInterface.class, UpperMiddle.class, LowerMiddle.class, Parent.class,
                SomeInterface.class, OtherInterface.class, Object.class
        );
    }