def oriented(square, desired):
    """ Return True if the given square is oriented as desired.
    """
    success = True
    neighbors = square.neighbors
    for side,id_ in desired.items():
        if id_ is None:
            success &= (side not in neighbors)
        else:
            success &= (side in neighbors and neighbors[side] == id_)
        if not success:
            return success
    return success