public static Field findField(Class<?> clazz, String field, Class<?> type, int index) {
        int temp = index;
        for (Field f : clazz.getDeclaredFields())
            if ((field == null || f.getName().equals(field)) && type.isAssignableFrom(f.getType()) && temp-- <= 0)
                return f;
        if (clazz.getSuperclass() != null)
            return findField(clazz.getSuperclass(), field, type, index);
        return null;
    }