from typing import Optional
from typing import Union
from typing import Any


def ensure_list(arr: Optional[Union[Any, list[Any]]]) -> Optional[list[Any]]:
    """Wraps single value to list or return list as it is."""
    if arr is not None and not isinstance(arr, list):
        arr = [arr]
    return arr