code: Map<Integer, Pair<Integer, Integer>> constructRingMap(Map<Integer, List<Integer>> treeMap,
                                                                    Map<Integer, Integer> parentMap) {
          assert parentMap.get(0) == -1;
  
          List<Integer> sharedRing = constructShareRing(treeMap, parentMap, 0);
          assert sharedRing.size() == treeMap.size();
  
          Map<Integer, Pair<Integer, Integer>> ringMap = new LinkedHashMap<>(numWorkers);
          for(int r = 0; r < numWorkers; r++) {
              int rPrev = (r + numWorkers - 1) % numWorkers;
              int rNext = (r + 1) % numWorkers;
              ringMap.put(sharedRing.get(r), new Pair<>(sharedRing.get(rPrev), sharedRing.get(rNext)));
          }
          return ringMap;
      }
docs: Returns for each node with "rank" the previous and next node in DFS order. For the root the "previous"
  entry will be the last element, which will create a ring type structure.