getNextId () {
    const oldObjNum = this.obj_num
    let restoreOldObjNum = false

    // If there are any released numbers in the release stack,
    // use the last one instead of the next obj_num.
    // We need to temporarily use obj_num as that is what getId() depends on.
    if (this.releasedNums.length > 0) {
      this.obj_num = this.releasedNums.pop()
      restoreOldObjNum = true
    } else {
      // If we are not using a released id, then increment the obj_num.
      this.obj_num++
    }

    // Ensure the ID does not exist.
    let id = this.getId()
    while (this.getElem_(id)) {
      if (restoreOldObjNum) {
        this.obj_num = oldObjNum
        restoreOldObjNum = false
      }
      this.obj_num++
      id = this.getId()
    }
    // Restore the old object number if required.
    if (restoreOldObjNum) {
      this.obj_num = oldObjNum
    }
    return id
  }
Returns the next object Id as a string.
@returns {string} The next object Id to use.