One other thing to try if needed work be to to use Sqlite and keep the media file / Media with the most (max) links and remove the the rest – the script itself would not complicate but I have never tried (or needed to)
From your Count Trees screenshot, your database currently has double sets of each individual. Each of the doubles have different Record ID numbers (RIN). Those all need to be merged: