public static List<TypeAnnotationWriteHelper> writeNestedClass(
    StringBuilder sb,
    Type type,
    List<String> nestedTypes,
    List<TypeAnnotationWriteHelper> typeAnnWriteHelpers
  ) {
    List<ClassesProcessor.ClassNode> enclosingClasses = enclosingClassList();
    StringBuilder curPathBuilder = new StringBuilder(type.getValue().substring(0, type.getValue().lastIndexOf('/') + 1));
    for (int i = 0; i < nestedTypes.size(); i++) {
      String nestedType = nestedTypes.get(i);
      boolean shouldWrite = true;
      if (!enclosingClasses.isEmpty() && i != nestedTypes.size() - 1) {
        String enclosingType = enclosingClasses.remove(0).simpleName;
        shouldWrite = !nestedType.equals(enclosingType);
      }
      if (i == 0) { // the first annotation can be written already
        if (!sb.toString().isEmpty()) shouldWrite = true; // write if annotation exists
      } else {
        if (canWriteNestedTypeAnnotation(curPathBuilder + nestedType + '$', nestedTypes.subList(i + 1, nestedTypes.size()))) {
          List<TypeAnnotationWriteHelper> notWrittenTypeAnnotations = writeNestedTypeAnnotations(sb, typeAnnWriteHelpers);
          shouldWrite |= (notWrittenTypeAnnotations.size() != typeAnnWriteHelpers.size());
          typeAnnWriteHelpers = notWrittenTypeAnnotations;
          if (i != nestedTypes.size() - 1) popNestedTypeAnnotation(typeAnnWriteHelpers);
        }
      }
      if (shouldWrite) {
        sb.append(nestedType);
        curPathBuilder.append(nestedType);
        if (i != nestedTypes.size() - 1) {
          curPathBuilder.append('$');
          sb.append('.');
        }
      }
    }
    return typeAnnWriteHelpers;
  }
public static List<TypeAnnotationWriteHelper> writeNestedClass(
    StringBuilder sb,
    Type type,
    List<String> nestedTypes,
    List<TypeAnnotationWriteHelper> typeAnnWriteHelpers
  )