def visited(Q):
    """Visited states

    Params:
    -------
        * Q: dictionary of dictionaries
        Nested dictionary representing a table

    Returns:
    -------
        * vis: a list of unique visited states
    """
    vis = sorted([s for s in Q if any([v for v in Q[s].values()])])

    return vis