setMinLevelToZero() {
    const remap = new Map();
    let newLevel = 0;
    const uniqueSortedLevels = [...new Set(Object.values(this.levels))].sort(
      (a, b) => a - b
    );

    for (const level of uniqueSortedLevels) {
      remap.set(level, newLevel++);
    }

    for (const nodeId in this.levels) {
      if (Object.prototype.hasOwnProperty.call(this.levels, nodeId)) {
        this.levels[nodeId] = remap.get(this.levels[nodeId]);
      }
    }
  }
Small util method to set the minimum levels of the nodes to zero and
eliminate gaps (for cyclic).