How do nodes rebroacast transactions When a bitcoin node receive a new transaction, it rebroadcast it and stores it in its mempool. If the transaction gets into a block, then it is removed from the node's mempool.

But what happen when it is still unconfirmed after some blocks? How does it check which transactions to rebroadcast? Is there a priority list to choose which transaction to broadcast?
Nodes typically do not rebroadcast transactions. They have no reason to do so, it is not their problem if a transaction is not confirmed.

However if a wallet will likely rebroadcast its transactions, and only its transactions. Rebroadcasting works in the exact same way that broadcasting a transaction works. If nodes still have the transaction in their mempools, then they will ignore the transaction. Of course this means it will not propagate well if all of the nodes that a wallet is connected to already has the transaction but other nodes don't.