def find_or_create_artist(name): for artist in Artist.all(): if artist.name == name: return artist else: return Artist(name)