from typing import List
from typing import Union


def most_frequent_element(sequence: List[int]) -> Union[int, None]:
    """
    Returns the most frequent element in the sequence of natural numbers.
    If there are several most frequent elements, it returns the element with the smallest index.
    For an empty sequence returns None.

    >>> most_frequent_element([1,8,3,5,3,5,5])
    5
    >>> most_frequent_element([1,1,5,5,1,5])
    1
    >>> most_frequent_element([])
    """
    if not sequence:
        return None
    frequencies = {}

    for elem in sequence:
        if elem not in frequencies:
            frequencies[elem] = 0
        frequencies[elem] += 1

    most_frequent = None, -1
    for elem, freq in frequencies.items():
        if freq > most_frequent[1]:
            most_frequent = elem, freq

    return most_frequent[0]