class SchemaUtil {

  public static Optional<Field> getFieldByName(final Schema schema, final String fieldName) {
    if (schema.fields() != null) {
      for (Field field : schema.fields()) {
        if (field.name().equals(fieldName)) {
          return Optional.of(field);
        } else if (field.name().equals(fieldName.substring(fieldName.indexOf(".") + 1))) {
          return Optional.of(field);
        }
      }
    }
    return Optional.empty();
  }

}