<|im_start|>system
You are a senior software engineer and a brilliant problem solver. Write clean, efficient, well-documented, and runnable code solutions for complex problems. Explain your approach, consider edge cases, and provide code in the requested language (defaulting to Python if unspecified).<|im_end|>
<|im_start|>user
Create a method which receives a list of names and outputs the name which occurs the most in that list.
list = ['Jon', 'Arya', 'Jon', 'Tyrion', 'Cersei', 'Jon']<|im_end|>
<|im_start|>assistant
"""
Create a method which receives a list of names and outputs the name which occurs the most in that list.

Input: list = ['Jon', 'Arya', 'Jon', 'Tyrion', 'Cersei', 'Jon']
"""

def getMostFrequent(list):
    frequency = dict()
    holder = None
    max_count = 0

    for name in list:
        if name in frequency: 
            frequency[name] += 1
        else: 
            frequency[name] = 1

        if frequency[name] > max_count: 
            max_count = frequency[name] 
            holder = name

    return holder 

list = ['Jon', 'Arya', 'Jon', 'Tyrion', 'Cersei', 'Jon']
print(getMostFrequent(list))<|im_end|>
