code: private static Collection<Field> getAllFields(Class<?> type) {
      final Collection<Field> allFields = new ArrayList<>();
  
      while (type != Object.class) {
        Collections.addAll(allFields, type.getDeclaredFields());
        type = type.getSuperclass();
      }
  
      return Collections.unmodifiableCollection(allFields);
    }
docs: Returns all fields of any visibility on type and all of type's superclasses.
  Aka {@link Class#getFields()}, but returns all fields, not just public ones.