private <T> Template<T> lookupInterfaceTypes(Class<T> targetClass) {
        Class<?>[] infTypes = targetClass.getInterfaces();
        Template<T> tmpl = null;
        for (Class<?> infType : infTypes) {
            tmpl = (Template<T>) cache.get(infType);
            if (tmpl != null) {
                register(targetClass, tmpl);
                return tmpl;
            } else {
                try {
                    tmpl = (Template<T>) parent.lookupCache(infType);
                    if (tmpl != null) {
                        register(targetClass, tmpl);
                        return tmpl;
                    }
                } catch (NullPointerException e) { // ignore
                }
            }
        }
        return tmpl;
    }