for item in iterable:
    if item == element:
        count += 1
if isinstance(item, list):
    count += flatten_count(item, element)
return count
Python - Finding each occurrence of a value in a mixed array (integers, lists)