def METHOD_NAME(self, node):
    """ensures that node has a unique id, preferring an already existing id"""
    if "id" in node.attrib:
        slug = node.attrib["id"]
    else:
        content = node.text.strip()
        slug = wiki_slugify(content, "-", unicode=True)
    candidate = slug
    i = 1
    while candidate in self.slugs:
        candidate = "{}_{}".format(slug, i)
        i += 1
    self.slugs[candidate] = True
    node.attrib["id"] = candidate
    return candidate