The script could also check if the tabs are actually linked and just do a normal Go BACK if they aren't.
You could probably do it without using a script, by swapping source/dest between commands, but it's messier (the file display border may flicker from the two changes, and you couldn't add any extra logic to make it more intelligent when the tabs were not linked).