def return_list_smart(func):
    """ 
        Decorator. If a function is trying to return a list
        of length 1 it returns the list element instead
    """

    def inner(*args, **kwargs):
        out = func(*args, **kwargs)
        if not out:
            return None

        if len(out) == 1:
            return out[0]
        else:
            return out

    return inner