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?