docs: private void rewriteDuplicates(final Element root) {
          // collect href and copy-to
          final Map<URI, Map<Set<URI>, List<Attr>>> refs = new HashMap<>();
          for (final Element e: getTopicrefs(root)) {
              Attr attr = e.getAttributeNode(BRANCH_COPY_TO);
              if (attr == null) {
                  attr = e.getAttributeNode(ATTRIBUTE_NAME_COPY_TO);
                  if (attr == null) {
                      attr = e.getAttributeNode(ATTRIBUTE_NAME_HREF);
                  }
              }
              if (attr != null) {
                  final URI h = stripFragment(map.resolve(attr.getValue()));
                  Map<Set<URI>, List<Attr>> attrsMap = refs.computeIfAbsent(h, k -> new HashMap<>());
                  final Set<URI> currentFilter = getBranchFilters(e);
                  List<Attr> attrs = attrsMap.computeIfAbsent(currentFilter, k -> new ArrayList<>());
                  attrs.add(attr);
              }
          }
          // check and rewrite
          for (final Map.Entry<URI, Map<Set<URI>, List<Attr>>> ref: refs.entrySet()) {
              final Map<Set<URI>, List<Attr>> attrsMaps = ref.getValue();
              if (attrsMaps.size() > 1) {
                  if (attrsMaps.containsKey(Collections.EMPTY_LIST)) {
                      attrsMaps.remove(Collections.EMPTY_LIST);
                  } else {
                      Set<URI> first = attrsMaps.keySet().iterator().next();
                      attrsMaps.remove(first);
                  }
                  int i = 1;
                  for (final Map.Entry<Set<URI>, List<Attr>> attrsMap: attrsMaps.entrySet()) {
                      final String suffix = "-" + i;
                      final List<Attr> attrs = attrsMap.getValue();
                      for (final Attr attr: attrs) {
                          final String gen = addSuffix(attr.getValue(), suffix);
                          logger.info(MessageUtils.getMessage("DOTJ065I", attr.getValue(), gen)
                                  .setLocation(attr.getOwnerElement()).toString());
                          if (attr.getName().equals(BRANCH_COPY_TO)) {
                              attr.setValue(gen);
                          } else {
                              attr.getOwnerElement().setAttribute(BRANCH_COPY_TO, gen);
                          }
  
                          final URI dstUri = map.resolve(gen);
                          if (dstUri != null) {
                              final FileInfo hrefFileInfo = job.getFileInfo(currentFile.resolve(attr.getValue()));
                              if (hrefFileInfo != null) {
                                  final URI newResult = addSuffix(hrefFileInfo.result, suffix);
                                  final FileInfo.Builder dstBuilder = new FileInfo.Builder(hrefFileInfo)
                                          .uri(dstUri)
                                          .result(newResult);
                                  if (hrefFileInfo.format == null) {
                                      dstBuilder.format(ATTR_FORMAT_VALUE_DITA);
                                  }
                                  final FileInfo dstFileInfo = dstBuilder.build();
                                  job.add(dstFileInfo);
                              }
                          }
                      }
                      i++;
                  }
              }
          }
      }