A node in the network announces itself. Every other node stores from which node the announce message came the fastest. When a node gets a package for a node, it sends the packet to the node stored in the database which is assumed to be the fastest way.
For more details:
reticulum.network/manual/understanding.html#the-announce-mechanism-in-detail