Clean all unreferenced state groups when purging
The purging code already cleans unreferenced state groups up the graph when purging, ie. previous state groups that are not referenced anymore because we are deleting their children. However, some state groups are completely unreferenced, and thus never cleaned, because no code even looks for them. They could be detected and cleaned on a regular basis, yet because they cause the room purging code to spam the database with useless de-delta-ed lines, it would be nice to detect and clean them early before things go wrong. See https://github.com/element-hq/synapse/issues/9406 for details about the issue as seen in the wild. We are interested in state groups *down* the graph from those we delete, which are the ones we might accidently de-delta. Hence we replace the code that climbs up the graph with a broader search for state groups to delete, browsing all linked groups, up and down the graph.