public static List<TypeAnnotationWriteHelper> writeTypeAnnotationBeforeType(
    Type type,
    StringBuilder sb,
    List<TypeAnnotationWriteHelper> typeAnnWriteHelpers
  ) {
    return typeAnnWriteHelpers.stream().filter(typeAnnWriteHelper -> { // TODO remove duplicate
      if (typeAnnWriteHelper.getAnnotation().isWrittenBeforeType(type)) {
        typeAnnWriteHelper.writeTo(sb);
        return false;
      }
      StructTypePathEntry pathEntry = typeAnnWriteHelper.getPaths().peek();
      if (pathEntry != null
          && pathEntry.getTypePathEntryKind() == StructTypePathEntry.Kind.NESTED.getId()
          && type.isAnnotatable()
      ) typeAnnWriteHelper.getPaths().pop();
      return true;
    }).collect(Collectors.toList());
  }
public static List<TypeAnnotationWriteHelper> writeTypeAnnotationBeforeType(
    Type type,
    StringBuilder sb,
    List<TypeAnnotationWriteHelper> typeAnnWriteHelpers
  )