How would you find the most frequent element in an array?
Implement most_frequent_element(nums) for a non-empty array of integers. Return the value with the highest frequency; if multiple values tie, return the one that appears first in the array.
def most_frequent_element(nums):