def get_leaf_type(xpath):
  """Gets the leaf type from the xpath."""
  # Example:
  # "/div[1]/span[2]/br[1]"-->"br"
  # "/div[1]/span[2]/tail"-->"span"
  # "/div[1]/span[2]/a"-->"a"
  html_tags = xpath.split("/")
  tag = html_tags[-1]
  if tag.startswith("tail"):
    tag = html_tags[-2]
  if tag.find("[") >= 0:
    return tag[:tag.find("[")]  # Clean the tag index.
  else:
    return tag