Dancing Hoskuld
Deity
I have found one thing that can't be done for this in Python. There are no Python functions available to add and remove a nation from a team. Thus if you "upgrade" a nation it will not remain on the same team as the old nation.