private static <A extends Annotation> Optional<A> resolveNestedAnnotations(Stream<Annotation> initialAnnotations, Class<A> annotationClass,
                                                                               Predicate<Annotation> metaAnnotationCheck) {
        List<Annotation> annotations = AnnotationHelper.extractAnnotationsFromMetaAnnotations(initialAnnotations, metaAnnotationCheck);
        while (!annotations.isEmpty()) {
            final Optional<Annotation> directAnnotation = annotations.stream()
                    .filter(annotationClass::isInstance)
                    .findFirst();
            if (directAnnotation.isPresent()) {
                return directAnnotation.map(annotationClass::cast);
            }
            annotations = AnnotationHelper.extractAnnotationsFromMetaAnnotations(annotations.stream(), metaAnnotationCheck);
        }
        return Optional.empty();
    }
Select the instance of the specified annotation type from the given annotatedElement's annotations. 

<p>Also considering meta annotations (i.e., annotations on annotations) if a meta annotation is 
deemed eligible according to the given <code>metaAnnotationPredicate</code>.</p>

@param <A> the generic type of the annotation
@param annotatedElement where to look for the specified annotation
@param annotationClass the class of the annotation to look for
@param metaAnnotationCheck the predicate indicating meta annotations
@return an empty entry if not found
jsonschema-generator/src/main/java/com/github/victools/jsonschema/generator/AnnotationHelper.java