def get_single_series(
    ts: Optional[
        Union[TimeSeries, Sequence[TimeSeries], Sequence[Sequence[TimeSeries]]]
    ],
) -> Optional[TimeSeries]:
    """Returns a single (first) TimeSeries or `None` from `ts`. Returns `ts` if  `ts` is a TimeSeries, `ts[0]` if
    `ts` is a `Sequence[TimeSeries]`, and `ts[0][0]` if `ts` is a `Sequence[Sequence[TimeSeries]]`.
    Otherwise, returns `None`.

    Parameters
    ----------
    ts
        None, a single `TimeSeries`, a sequence of `TimeSeries`, or a sequence of sequences of `TimeSeries`.

    Returns
    -------
    TimeSeries
        `ts` if  `ts` is a TimeSeries, `ts[0]` if `ts` is a Sequence of TimeSeries. Otherwise, returns `None`

    """
    seq_type = get_series_seq_type(ts)
    if seq_type <= SeriesType.SINGLE:
        # `None` and `TimeSeries`
        return ts
    elif seq_type == SeriesType.SEQ:
        return ts[0]
    else:
        return ts[0][0]
Returns a single (first) TimeSeries or `None` from `ts`. Returns `ts` if  `ts` is a TimeSeries, `ts[0]` if
    `ts` is a `Sequence[TimeSeries]`, and `ts[0][0]` if `ts` is a `Sequence[Sequence[TimeSeries]]`.
    Otherwise, returns `None`.

    Parameters
    ----------
    ts
        None, a single `TimeSeries`, a sequence of `TimeSeries`, or a sequence of sequences of `TimeSeries`.

    Returns
    -------
    TimeSeries
        `ts` if  `ts` is a TimeSeries, `ts[0]` if `ts` is a Sequence of TimeSeries. Otherwise, returns `None`

    
darts/utils/ts_utils.py