docs: private static Assignment getBestAssignmentGiven(CliqueTree cliqueTree, int factorNum,
        Set<Integer> visitedFactors, Assignment a) {
      Factor curFactor = cliqueTree.getMarginal(factorNum);
      List<Assignment> bestAssignments = curFactor.conditional(a).getMostLikelyAssignments(1);
      if (bestAssignments.size() == 0) {
        // This condition implies that the factor graph does not have a positive
        // probability assignment.
        throw new ZeroProbabilityError();
      }
  
      Assignment best = bestAssignments.get(0).union(a);
      if (curFactor.getUnnormalizedLogProbability(best) == Double.NEGATIVE_INFINITY) {
        throw new ZeroProbabilityError();
      }
  
      visitedFactors.add(factorNum);
  
      for (int adjacentFactorNum : cliqueTree.getNeighboringFactors(factorNum)) {
        if (!visitedFactors.contains(adjacentFactorNum)) {
          Assignment bestChild = getBestAssignmentGiven(cliqueTree, adjacentFactorNum,
              visitedFactors, best).removeAll(best.getVariableNumsArray());
          best = best.union(bestChild);
        }
      }
      return best;
    }