docs: private static Collection<Set<Fragment>> getConnectedFragmentSets(Set<Fragment> allFragments) {
          // TODO this could be implemented in a more readable way (eg. using a graph + BFS etc.)
          final Map<Integer, Set<Variable>> varSetMap = new HashMap<>();
          final Map<Integer, Set<Fragment>> fragmentSetMap = new HashMap<>();
          final int[] index = {0};
          allFragments.forEach(fragment -> {
              Set<Variable> fragmentVarNameSet = Sets.newHashSet(fragment.vars());
              List<Integer> setsWithVarInCommon = new ArrayList<>();
              varSetMap.forEach((setIndex, varNameSet) -> {
                  if (!Collections.disjoint(varNameSet, fragmentVarNameSet)) {
                      setsWithVarInCommon.add(setIndex);
                  }
              });
  
              if (setsWithVarInCommon.isEmpty()) {
                  index[0] += 1;
                  varSetMap.put(index[0], fragmentVarNameSet);
                  fragmentSetMap.put(index[0], Sets.newHashSet(fragment));
              } else {
                  Iterator<Integer> iterator = setsWithVarInCommon.iterator();
                  Integer firstSet = iterator.next();
                  varSetMap.get(firstSet).addAll(fragmentVarNameSet);
                  fragmentSetMap.get(firstSet).add(fragment);
                  while (iterator.hasNext()) {
                      Integer nextSet = iterator.next();
                      varSetMap.get(firstSet).addAll(varSetMap.remove(nextSet));
                      fragmentSetMap.get(firstSet).addAll(fragmentSetMap.remove(nextSet));
                  }
              }
          });
          return fragmentSetMap.values();
      }