Cleanup of unused records in the acidfree_hierarchy table

For some reason my "acidfree_hierarchy" table (part of the Acidfree Drupal module installation) contained a lot of records in my DB with a "child" value that has no corresponding record in the "nodes" table. Here's how to get rid of these records ...

You can check for the existence of such records with the following query:
select
  count(*)
from
  acidfree_hierarchy ah
  left outer join node n on ah.child = n.nid
where 1
  and n.nid is null

And delete these records with this:
delete ah from
  acidfree_hierarchy as ah
  left outer join node as n on ah.child = n.nid
where n.nid is null

PS: I suspect that the mass delete functionality might have left those records there. Shock