def key_type(key):
  """String identifying if the key is a 'name' or an 'ID', or '' for None.

  This is most useful when paired with key_id_or_name_as_string.

  Args:
    key: A datastore Key

  Returns:
    The type of the leaf identifier of the Key, 'ID', 'name', or ''.
  """
  if key.id():
    return 'ID'
  elif key.name():
    return 'name'
  else:
    return ''