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