from typing import Generator
from typing import Union


def get_next_generated_value_or_none(generator: Generator[int, None, None]) \
        -> Union[int, None]:
    """
    Returns the next element of an argument generator, or None, if a
    StopIteration exception arose.
    """
    try:
        return next(generator)
    except StopIteration:
        pass