I had a glitch in a script that caused some unwanted contact merges to happen programmatically:
$result = civicrm_api3('Contact', 'merge', [ 'to_remove_id' => $existingContactId, 'to_keep_id' => $contactId, 'mode' => "aggressive",]);
Fortunately, I had the Detailed Logging setting enabled. In theory, I could pull the change log for each unwanted merge and "revert" the merge. Does anyone know of an extension or script I can look at to accomplish this?