from typing import List
from typing import Any


def nthOrLastOrNone(list: List[Any], n: int) -> Any:
    """
    Return the n-th element of a list; if it is not set, return
    the last element of the list; if it is not set, return none.
    """
    if not list:
        return None
    return list[n] if len(list) > n else list[-1]