def _deal_with_axis(obj, axis):
    """Handle the `axis` parameter 

    Parameters
    ----------
    obj: DimArray object
    axis: `int` or `str` or `tuple` or None

    Returns
    -------
    newobj: reshaped obj if axis is tuple otherwise obj
    idx   : axis index
    name  : axis name
    """
    # before applying the function on the collapsed array
    if type(axis) in (tuple, list):
        idx = 0
        newobj = obj.flatten(axis, insert=idx)
        #idx = obj.dims.index(axis[0])  # position where the new axis has been inserted
        #ax = newobj.axes[idx] 
        ax = newobj.axes[0]
        name = ax.name

    else:
        newobj = obj
        idx, name = obj._get_axis_info(axis) 

    return newobj, idx, name