private <T> Template<T> lookupSuperclasses(Class<T> targetClass) {
        Class<?> superClass = targetClass.getSuperclass();
        Template<T> tmpl = null;
        if (superClass != null) {
            for (; superClass != Object.class; superClass = superClass
                    .getSuperclass()) {
                tmpl = (Template<T>) cache.get(superClass);
                if (tmpl != null) {
                    register(targetClass, tmpl);
                    return tmpl;
                } else {
                    try {
                        tmpl = (Template<T>) parent.lookupCache(superClass);
                        if (tmpl != null) {
                            register(targetClass, tmpl);
                            return tmpl;
                        }
                    } catch (NullPointerException e) { // ignore
                    }
                }
            }
        }
        return tmpl;
    }