def modes(nums):
    """Returns the most frequently occurring items in the given list, nums"""
    if len(nums) == 0:
        return []
    # Create a dictionary of numbers to how many times they occur in the list
    frequencies = {}
    for num in nums:
        frequencies[num] = 1 + frequencies.get(num, 0)
    # How many times each mode occurs in nums:
    max_occurrences = max(frequencies.values())
    return [num for num, frequency in frequencies.items() if frequency == max_occurrences]