if (leader == null && currentLeader != null && candidates.contains(currentLeader)) { leader = currentLeader; }
  public static String getLeader(Set candidates, List votes) {    String leader = null;    // Count the votes and see if there's a unanimous selection    int numVotes = votes.size();    if (numVotes == 1) {      leader = candidates.contains(votes.get(0)) ? (String)votes.get(0) : null;    } else if (numVotes > 1) {      String first = (String)votes.get(0);      for (int i = 1; i < numVotes; i++) {        if (!first.equals((String)votes.get(i))) {          first = null;          break;        }      }      leader = (first != null && candidates.contains(first)) ? first : null;    }    logger.debug("getLeader:" +                 " candidates=" + candidates +                 " votes=" + votes +                 " leader=" + leader);    return leader;  }