You need a takeWhile method which will appear in JDK-9 only. Currently you can use a back-port which is available, for example, in my StreamEx library:
Stream> stream = StreamEx.iterate(value.getClass(), Class::getSuperClass)
.takeWhile(Objects::nonNull);
In JDK-9 just replace StreamEx
with Stream
.