Andy Salnikov notes that this bit:
https://github.com/lsst/daf_butler/blob/master/python/lsst/daf/butler/registries/sqlRegistry.py#L548-L550
is looping over refs many times, instead of just the outer loop.