docs: public static AbstractTopology mutateRecoverTopology(AbstractTopology topology, Set<Integer> liveHosts,
              int localHostId, String placementGroup, Set<Integer> recoverPartitions) {
  
           Host replaceHost = null;
           for (Host h : topology.hostsById.values()) {
  
               // filter out
               if (liveHosts.contains(h.id) || !h.haGroup.equalsIgnoreCase(placementGroup)) {
                   continue;
               }
               if (replaceHost == null) {
                   replaceHost = h;
               }
  
               // use the matched host. if no match found, use any one available.
               if (recoverPartitions != null && !recoverPartitions.isEmpty()) {
                   if (h.getPartitionIdList().equals(recoverPartitions)) {
                       replaceHost = h;
                       break;
                   }
               }
           }
  
           if (replaceHost == null) {
              return null;
           }
  
           Integer replaceHostId = replaceHost.id;
  
           ImmutableMap.Builder<Integer, Partition> partitionsByIdBuilder = ImmutableMap.builder();
           ArrayList<Integer> hostIds = new ArrayList<>();
  
           for (Map.Entry<Integer, Partition> entry : topology.partitionsById.entrySet()) {
               Partition partition = entry.getValue();
               boolean modified = false;
               for (Integer id : partition.hostIds) {
                   if (id.equals(replaceHostId)) {
                       modified = true;
                       hostIds.add(localHostId);
                   } else {
                       hostIds.add(id);
                   }
               }
  
               if (modified) {
                   partition = new Partition(partition.id,
                           replaceHostId.equals(partition.leaderHostId) ? localHostId : partition.leaderHostId, hostIds);
               }
  
               partitionsByIdBuilder.put(entry.getKey(), partition);
               hostIds.clear();
           }
  
           ImmutableMap<Integer, Partition> partitionsById = partitionsByIdBuilder.build();
           liveHosts.add(Integer.valueOf(localHostId));
           ImmutableMap.Builder<Integer, Host> hostsByIdBuilder = ImmutableMap.builder();
           for (Map.Entry<Integer, Host> entry : topology.hostsById.entrySet()) {
               Integer id = entry.getKey().intValue() == replaceHostId ? localHostId : entry.getKey();
               hostsByIdBuilder.put(id, new Host(entry.getValue(), id, partitionsById,
                               !liveHosts.contains(id)));
           }
  
           return new AbstractTopology(topology, hostsByIdBuilder.build(), partitionsById);
       }