docs: private ImmutableSetMultimap<Class<? extends Annotation>, Element> validElements(
        ImmutableMap<String, Optional<? extends Element>> deferredElements,
        RoundEnvironment roundEnv) {
      ImmutableSetMultimap.Builder<Class<? extends Annotation>, Element>
          deferredElementsByAnnotationBuilder = ImmutableSetMultimap.builder();
      for (Entry<String, Optional<? extends Element>> deferredTypeElementEntry :
          deferredElements.entrySet()) {
        Optional<? extends Element> deferredElement = deferredTypeElementEntry.getValue();
        if (deferredElement.isPresent()) {
          findAnnotatedElements(
              deferredElement.get(),
              getSupportedAnnotationClasses(),
              deferredElementsByAnnotationBuilder);
        } else {
          deferredElementNames.add(ElementName.forTypeName(deferredTypeElementEntry.getKey()));
        }
      }
  
      ImmutableSetMultimap<Class<? extends Annotation>, Element> deferredElementsByAnnotation =
          deferredElementsByAnnotationBuilder.build();
  
      ImmutableSetMultimap.Builder<Class<? extends Annotation>, Element> validElements =
          ImmutableSetMultimap.builder();
  
      Set<ElementName> validElementNames = new LinkedHashSet<ElementName>();
  
      // Look at the elements we've found and the new elements from this round and validate them.
      for (Class<? extends Annotation> annotationClass : getSupportedAnnotationClasses()) {
        // This should just call roundEnv.getElementsAnnotatedWith(Class) directly, but there is a bug
        // in some versions of eclipse that cause that method to crash.
        TypeElement annotationType = elements.getTypeElement(annotationClass.getCanonicalName());
        Set<? extends Element> elementsAnnotatedWith =
            (annotationType == null)
                ? ImmutableSet.<Element>of()
                : roundEnv.getElementsAnnotatedWith(annotationType);
        for (Element annotatedElement :
            Sets.union(elementsAnnotatedWith, deferredElementsByAnnotation.get(annotationClass))) {
          if (annotatedElement.getKind().equals(PACKAGE)) {
            PackageElement annotatedPackageElement = (PackageElement) annotatedElement;
            ElementName annotatedPackageName =
                ElementName.forPackageName(annotatedPackageElement.getQualifiedName().toString());
            boolean validPackage =
                validElementNames.contains(annotatedPackageName)
                    || (!deferredElementNames.contains(annotatedPackageName)
                        && validateElement(annotatedPackageElement));
            if (validPackage) {
              validElements.put(annotationClass, annotatedPackageElement);
              validElementNames.add(annotatedPackageName);
            } else {
              deferredElementNames.add(annotatedPackageName);
            }
          } else {
            TypeElement enclosingType = getEnclosingType(annotatedElement);
            ElementName enclosingTypeName =
                ElementName.forTypeName(enclosingType.getQualifiedName().toString());
            boolean validEnclosingType =
                validElementNames.contains(enclosingTypeName)
                    || (!deferredElementNames.contains(enclosingTypeName)
                        && validateElement(enclosingType));
            if (validEnclosingType) {
              validElements.put(annotationClass, annotatedElement);
              validElementNames.add(enclosingTypeName);
            } else {
              deferredElementNames.add(enclosingTypeName);
            }
          }
        }
      }
  
      return validElements.build();
    }