public static <T extends Annotation> T digAnnotation( Class<?> target, Class<T> annotationType, List<Class<? extends Annotation>> visited) { T result = target.getAnnotation(annotationType); if (result == null) { for (Annotation a : target.getAnnotations()) { if (!visited.contains(a.annotationType())) { visited.add(a.annotationType()); result = digAnnotation(a.annotationType(), annotationType, visited); if (result != null) { return result; } } } } return result; }