def METHOD_NAME(self, lib, query):
    """Print a listing of albums missing from each artist in the library
    matching query.
    """
    total = self.config['total'].get()
    albums = lib.albums(query)
    # build dict mapping artist to list of their albums in library
    albums_by_artist = defaultdict(list)
    for alb in albums:
        artist = (alb['albumartist'], alb['mb_albumartistid'])
        albums_by_artist[artist].append(alb)
    total_missing = 0
    # build dict mapping artist to list of all albums
    for artist, albums in albums_by_artist.items():
        if artist[1] is None or artist[1] == "":
            albs_no_mbid = ["'" + a['album'] + "'" for a in albums]
            self._log.info(
                "No musicbrainz ID for artist '{}' found in album(s) {}; "
                "skipping", artist[0], ", ".join(albs_no_mbid)
            )
            continue
        try:
            resp = musicbrainzngs.browse_release_groups(artist=artist[1])
            release_groups = resp['release-group-list']
        except MusicBrainzError as err:
            self._log.info(
                "Couldn't fetch info for artist '{}' ({}) - '{}'",
                artist[0], artist[1], err
            )
            continue
        missing = []
        present = []
        for rg in release_groups:
            missing.append(rg)
            for alb in albums:
                if alb['mb_releasegroupid'] == rg['id']:
                    missing.remove(rg)
                    present.append(rg)
                    break
        total_missing += len(missing)
        if total:
            continue
        missing_titles = {rg['title'] for rg in missing}
        for release_title in missing_titles:
            print_("{} - {}".format(artist[0], release_title))
    if total:
        print(total_missing)