code: private static Optional<Schema> isOfOptionType(Schema schema) {
      Preconditions.checkNotNull(schema);
  
      // If not of type UNION, cant be an OPTION
      if (!Schema.Type.UNION.equals(schema.getType())) {
        return Optional.<Schema>absent();
      }
  
      // If has more than two members, can't be an OPTION
      List<Schema> types = schema.getTypes();
      if (null != types && types.size() == 2) {
        Schema first = types.get(0);
        Schema second = types.get(1);
  
        // One member should be of type NULL and other of non NULL type
        if (Schema.Type.NULL.equals(first.getType()) && !Schema.Type.NULL.equals(second.getType())) {
          return Optional.of(second);
        } else if (!Schema.Type.NULL.equals(first.getType()) && Schema.Type.NULL.equals(second.getType())) {
          return Optional.of(first);
        }
      }
  
      return Optional.<Schema>absent();
    }
docs: *
  Check if the Avro Schema is of type OPTION
  ie. [null, TYPE] or [TYPE, null]
  @param schema Avro Schema to check
  @return Optional Avro Typed data if schema is of type OPTION