def _get_extreme_value(
    *args: int | float,
    stat: str = "max",
) -> int | float:
    """
    Get either the maximum or minimum value from a list of numeric values.
    """

    # Ensure that `stat` is either 'max' or 'min'
    _match_arg(stat, lst=["max", "min"])

    # Remove any None values from the `args` list
    args = [val for val in args if val is not None]

    # Flatten the `args` list which may contain lists and scalar values
    val_list = _flatten_list(args)

    # Remove missing values from the `val_list`
    val_list = _remove_na_from_list(val_list)

    # Remove None values from the `val_list`
    val_list = [val for val in val_list if val is not None]

    if stat == "max":
        extreme_val = max(val_list)
    else:
        extreme_val = min(val_list)

    return extreme_val

    Get either the maximum or minimum value from a list of numeric values.
    
great_tables/_utils_nanoplots.py