def assign_to_room(person, room=None):
    """Assign a person to a room.
        <room_name> is optional.
    """
    # find a person by name
    if type(person) is str:
        person = Amity.find_person(person)
    # find a room by name if specified
    if type(room) is str:
        room = Amity.find_room(room)
        # is the room an office?
    if isinstance(room, Office):
        if not person.has_office():
            Manager.assign_to_office(person, room)
        # is the room a living space?
    if isinstance(room, LivingSpace):
        if person.can_have_living_space() and \
                not person.has_living_space():
            Manager.assign_to_living_space(person, room)
    elif room is None:
        if not person.has_office():
            Manager.assign_to_office(person)
        if isinstance(person, Fellow) and person.can_have_living_space():
            if not person.has_living_space():
                Manager.assign_to_living_space(person)