docs: private static Factor computeMarginal(CliqueTree cliqueTree, int factorNum, boolean useSumProduct) {
      Set<Integer> factorNumsToCombine = Sets.newHashSet(cliqueTree.getNeighboringFactors(factorNum));
      factorNumsToCombine.removeAll(cliqueTree.getFactorsInMarginal(factorNum));
  
      List<Factor> factorsToCombine = Lists.newArrayList();
      for (int adjacentFactorNum : factorNumsToCombine) {
        Factor message = cliqueTree.getMessage(adjacentFactorNum, factorNum);
        Preconditions.checkState(message != null, "Invalid message passing order! Trying to pass %s -> %s",
            adjacentFactorNum, factorNum);
        factorsToCombine.add(message);
      }
  
      Factor newMarginal = cliqueTree.getMarginal(factorNum).product(factorsToCombine);
      cliqueTree.setMarginal(factorNum, newMarginal);
      cliqueTree.addFactorsToMarginal(factorNum, factorNumsToCombine);
  
      return newMarginal;
    }