def _most_popular_gender(self, name, counter):
if name not in self.names:<EOL><INDENT>return self.unknown_value<EOL><DEDENT>max_count, max_tie = (<NUM_LIT:0>, <NUM_LIT:0>)<EOL>best = self.names[name].keys()[<NUM_LIT:0>]<EOL>for gender, country_values in self.names[name].items():<EOL><INDENT>count, tie = counter(country_values)<EOL>if count > max_count or (count == max_count and tie > max_tie):<EOL><INDENT>max_count, max_tie, best = count, tie, gender<EOL><DEDENT><DEDENT>return best if max_count > <NUM_LIT:0> else self.unknown_value<EOL>
Finds the most popular gender for the given name counting by given counter