ensureId

If the given element already has an ID, return it. If not, generate a previously unused ID and return that