from typing import OrderedDict


def skip_nan_tracks(tracks):
    """Filter tracks

    Args:
      tracks: dictionary or OrderedDict of arrays with ndim >=2 and same second dimension

    Returns:
      OrderedDict of tracks
    """
    if tracks is None:
        return tracks

    if isinstance(tracks, OrderedDict):
        return OrderedDict([(track, arr)
                            for track, arr in tracks.items() if arr is not None])
    elif isinstance(tracks, dict):
        return {track: arr
                for track, arr in tracks.items() if arr is not None}
    elif isinstance(tracks, list):
        return [(track, arr)
                for track, arr in tracks if arr is not None]
    else:
        raise ValueError("Tracks need to be either dict or OrderedDict")