def majority(samples, ignore_none=True):
    """
    Find the most frequent element in a list.

    Arguments:
        samples (list): Input list. Its elements must be hashable.
        ignore_none (bool): If None is a valid value.

    Returns:
        object: The most frequent element in samples. Returns none if the input list is empty.
    """
    freq_dict = {}
    most_freq_ele = None
    highest_freq = 0
    for element in samples:
        if ignore_none and element is None:
            continue
        if element not in freq_dict:
            freq_dict[element] = 0
        freq = freq_dict[element] + 1
        freq_dict[element] = freq
        if freq > highest_freq:
            highest_freq = freq
            most_freq_ele = element
    return most_freq_ele