code: List<Integer> constructShareRing(Map<Integer, List<Integer>> treeMap,
                                              Map<Integer, Integer> parentMap,
                                              int rank) {
          Set<Integer> connectionSet = new LinkedHashSet<>(treeMap.get(rank));
          connectionSet.remove(parentMap.get(rank));
          if(connectionSet.isEmpty()) {
              return Collections.singletonList(rank);
          } else {
              List<Integer> ringSeq = new LinkedList<>();
              ringSeq.add(rank);
              int cnt = 0;
              for(Integer n : connectionSet) {
                  List<Integer> vConnSeq = constructShareRing(treeMap, parentMap, n);
                  cnt++;
                  if(connectionSet.size() == cnt) {
                      Collections.reverse(vConnSeq);
                  }
                  ringSeq.addAll(vConnSeq);
              }
              return ringSeq;
          }
  
      }
docs: Returns a DFS (root, DFS(left_child), DFS(right)child) order from root with given rank.