static <T extends RequestHandler> Optional<T> resolve(Class<T> type, RequestHandler h) {
        T candidate = type.isInstance(h) ? type.cast(h) : null;
        while (h instanceof DelegatedRequestHandler) {
            h = ((DelegatedRequestHandler) h).getDelegate();
            if (type.isInstance(h)) candidate = type.cast(h);
        }
        return Optional.ofNullable(candidate);
    }
Find delegated request handler of specified type recursively
Note that the returned handler may not be the innermost handler.
jdisc_core/src/main/java/com/yahoo/jdisc/handler/DelegatedRequestHandler.java