def been_there(state, check_dict, check):
    """
    Returns True, if the state is already visited
      
    state: a list representing the state to be checked
    check_dict: a dict storing the visited states
    check: a boolean value, if True, marks the given state as visited if it was not so 
    """
    
    key = str(state)
    if key in check_dict:
        return True
    else:
        if check:
            check_dict[key] = True
        return False