def find_duplicate_sta(db, collection='site'):
    """
    Scans collection requested (site is default be can be run on channel)
    for combinations of net:sta where the sta is not unique.   This can
    cause problem in associating data from css3.0 databases that do not
    have a net code for station names.   Returns a dict with sta names
    as key and a set container with net codes associated with that sta.
    The algorithm used here is a large memory algorithm but considered
    acceptable since the total number of instruments in a data set is
    not currently expected to be a limiting factor. If the collection
    were huge it would be better to use a well crafted incantation to
    mongodb.


    :param db: mspass Database handle or just a plain MongoDB database
      handle.  (mspass Database is a child of MongoDBs top level database
      handle)
    :param collection:  string defining the collection name to scan
      (default is site)
    :return: dict of stations with nonunique sta codes as the key.  The
      value returned in each field is a set container with net codes that use that
      sta code.
    """
    dbcol = db[collection]
    allsta = {}
    curs = dbcol.find()   # we do a brute force scan through the collection
    for rec in curs:
        if "net" in rec:
            net = rec["net"]
            sta = rec["sta"]
            if sta in allsta:
                val = allsta[sta]
                # note this works only because the set container behaves
                # like std::set and adds of duplicates do nothing
                val.add(net)
                allsta[sta] = val
            else:
                stmp = set()
                stmp.add(net)
                allsta[sta] = stmp
        else:
            sta = rec["sta"]
            print("find_duplicate_sta (WARNING):  ", collection,
                  " collection has an undefined net code for station",
                  sta)
            print("This is the full document from this collection")
            print(rec)
    # Now we have allsta with all unique station names.  We just look
    # for ones where the size of the set is not 1
    trouble_sta = {}
    for x in allsta:
        s = allsta[x]
        if len(s) > 1:
            trouble_sta[x] = s
    return trouble_sta