Filter then map instances from a stream and other Java 8 hiccups
What I can suggest is putting the subsequent filter()/map() steps into an extraction method of sorts:

@SuppressWarnings("rawtypes")
private static Optional&lt;Type&gt; extractMyType(Field field) {
    return Optional.of(field.getGenericType())...;
}


You can also put the filter()/map() steps as a single method:

private static &lt;T, R&gt; Optional&lt;R&gt; filterAndMap(T obj, Predicate&lt;? super T&gt; filter,
        Function&lt;? super T, ? extends R&gt; mapper) {
    return Optional.of(obj).filter(filter).map(mapper);
}


For convenience, you can create a cast() method that calls filterAndMap() to handle safe-casting:

private static &lt;T, R&gt; Optional&lt;R&gt; cast(T obj, Class&lt;R&gt; clazz) {
    return filterAndMap(obj, clazz::isInstance, v -&gt; (R) obj);
}


Then, the meat of extractMyType() effectively becomes three flatMap() operations:

@SuppressWarnings("rawtypes")
private static Optional&lt;Class&gt; extractMyType(Field field) {
    return Optional.of(field.getGenericType())
            .flatMap(v -&gt; cast(v, ParameterizedType.class))
            .flatMap(v -&gt; filterAndMap(v,
                            v1 -&gt; v1.getRawType() == MyTypeWrapper.class,
                            v1 -&gt; v1.getActualTypeArguments()[0]))
            .flatMap(v -&gt; cast(v, Class.class));
}


Finally, your collectMyTypes() method will just do a simple filter on the resulting Optional wrapper instances:

@SuppressWarnings("unchecked")
static Stream&lt;Class&lt;? extends MyType&gt;&gt; collectMyTypes(Object o) {
    return Reflection.lineage(o.getClass())
            .flatMap(c -&gt; Arrays.stream(c.getDeclaredFields()))
            .map(YourClass::extractMyType).filter(Optional::isPresent)
            .map(Optional::get);
}