private <T> Template<T> lookupGenericSuperclasses(ParameterizedType targetType) {
        Type rawType = targetType.getRawType();
        Template<T> tmpl = null;

        try {
            Class<?> superClass = ((Class) rawType).getSuperclass();
            if (superClass == null) {
                return null;
            }

            for (; superClass != Object.class; superClass = superClass.getSuperclass()) {
                tmpl = lookupGenericTypeImpl0(targetType, superClass);
                if (tmpl != null) {
                    register(targetType, tmpl);
                    return tmpl;
                }
            }
        } catch (ClassCastException e) { // ignore
        }

        return tmpl;
    }