public static Stack<Class<?>> getClassHierarchy(final Class<?> clazz) {
        final Stack<Class<?>> classHierarchy = new Stack<Class<?>>();
        Class<?> c = clazz;
        while (c != null) {
            classHierarchy.push(c);
            c = (isStatic(c.getModifiers())) ? null : c.getEnclosingClass();
        }
        return classHierarchy;
    }
public static Stack < Class < ? > > getClassHierarchy ( final Class < ? > clazz ) { final Stack < Class < ? > > classHierarchy = new Stack < Class < ? > > ( ) ; Class < ? > c = clazz ; while ( c != null ) { classHierarchy . push ( c ) ; c = ( isStatic ( c . getModifiers ( ) ) ) ? null : c . getEnclosingClass ( ) ; } return classHierarchy ; }
Returns a {@link Stack} of classes, representing the hierarchy of the given {@link Class}.

@param clazz the {@link Class} to retrieve the hierarchy for
@return the {@link Class} hierarchy