Gets the child at parent[idx], or all the children if idx == "*".

def get_children(parent, idx):
  """Gets the child at parent[idx], or all the children if idx == "*"."""
  if isinstance(parent, dict):
    if idx in parent:
      yield parent[idx]
    else:
      raise JSONPathError("Invalid path at {0}".format(idx))

  elif isinstance(parent, list):
    if idx == "*":
      yield from parent
    else:
      is_int, i = try_parse_int(idx)

      if is_int and i >= 0 and i < len(parent):
        yield parent[i]
      else:
        raise JSONPathError("Invalid list index: {0}".format(i))

  else:
    raise JSONPathError("Type {0} does not have children".format(type(parent).__name__))