code: private static Integer getFieldPathElementIndex(ApiError apiError, String field) {
      FieldPathElement[] fieldPathElements = apiError.getFieldPathElements();
      if (fieldPathElements == null) {
        return null;
      }
      for(int i = 0; i < fieldPathElements.length; i++) {
        FieldPathElement fieldPathElement = fieldPathElements[i];
        if (field.equals(fieldPathElement.getField())) {
          return fieldPathElement.getIndex();
        }
      }
      return null;
    }
docs: Returns the {@link FieldPathElement#getIndex()} for the specified {@code field} name, if
  present in the error's field path elements.
  
  @param apiError the error to inspect.
  @param field the name of the field to search for in the error's field path elements.
  @return the index of the entry with the specified field, or {@code null} if no such entry
  exists or the entry has a null index.