private List<Match> applyDirectMatchesToAssignment(List<Match> matches, Assignment assignment) {
   List<Match> remainingMatches = new ArrayList<Match>();
   for (Match match : matches) {
     if (match.to.size() == 1) {
       assignment.applyMatch(match, 0);
     } else {
       remainingMatches.add(match);
     }
   }
   return remainingMatches;
 }
  private void recursivelyBuildAndScoreAssignment(
      List<Match> matches, int depth, Assignment assignment, Min<Assignment> m) {
    if (depth == matches.size()) {
      double score = scoreAssignment(assignment);
      if (score < m.getMinValue()) {
        m.add(score, new Assignment(assignment));
      }

    } else {
      Match match = matches.get(depth);
      for (int i = 0; i < match.to.size(); ++i) {
        assignment.applyMatch(match, i);
        recursivelyBuildAndScoreAssignment(matches, depth + 1, assignment, m);
      }
    }
  }