Unless you continuously monitor window title changes, there's no really good way to completely automate this – and I find that sort of monitoring to be too intrusive (usually).
It ought not to be too hard to make macros to keep “bookmarks” of tabs though.
You could “mark” a tab, “mark” another tab, and then move between them.
You could add more than two.
You'd also need a “Clear Marks” macro.
See my Safari » Switch Tabs-Windows macro for a few ideas on how to activate the tabs/windows.
Hey there! I just saw this post, I know it's a little dated but this macro I made a while ago addresses your question I believe. While it does use title change triggers to monitor the tab index changes, I've used it for at least a year or so and has worked like a champ and hasn't interfered with any other macros/functionality yet, hope you dig it as well!
Kevin's macro is working out great, and has saved me many hours of design and development time. I have made some mods to expand its scope and fit my needs. If you are interested, you can follow this at my post here.