public static List<Tuple> recursivelyBuildTuples(int targetSize, int currentIndex, List<Client> fullList,
      List<Client> refList, boolean permutation) {
    List<Tuple> result = new ArrayList<>();
    if (currentIndex < targetSize - 1) {
      for (int index = 0; index < fullList.size(); index++) {
        List<Client> temp = new ArrayList<>(refList);
        temp.add(fullList.get(index));
        result.addAll(recursivelyBuildTuples(targetSize, currentIndex + 1,
            fullList.subList(permutation ? 0 : index, fullList.size()), temp, permutation));
      }
    } else {
      for (Client client : fullList) {
        List<Client> temp = new ArrayList<>(refList);
        temp.add(client);
        result.add(new Tuple(temp));
      }
    }
    return result;
  }
Build a list of tuple from given endpoints list, permutation or combination

@param targetSize   targeted tuple size
@param currentIndex index of the endpoint in the list
@param fullList     list of provided endpoints
@param refList      list of endpoint currently being built
@param permutation  true if this is permutation, false if combination

@return a list of tuples of endpoints.
KITE-Engine/src/main/java/org/webrtc/kite/config/Configurator.java