def METHOD_NAME(data_source):
    if isinstance(data_source, Dataset):
        data_source = data_source.all_data()
    if not isinstance(data_source, (YTSelectionContainer3D, type(None))):
        raise RuntimeError(
            "The data_source is not a valid 3D data container.\n"
            "Expected an object of type YTSelectionContainer3D but received "
            "an object of type %s." % type(data_source)
        )
    return data_source