def get_track_id_from_search_query(spotify_obj, search_query, artist_name):
    """Method that returns a track ID returned from the search using Spotify API
    (managed by spotipy.Spotify object passed to the method) for a given search query
    and expected artist name (or the first result's ID, if the name was not found)."""
    results = spotify_obj.search(search_query)

    try:
        for item in results['tracks']['items']:
            if item['artists'][0]['name'] == artist_name:
                return item['id']

        return results['tracks']['items'][0]['id']
    except IndexError:
        return None