If it becomes apparent that someone above you on your department’s org chart is a superstar, let them know that you want to join their team or continue to work with them as they move up. Especially if you sense you’d connect with them intellectually as well as emotionally.
Companies identify their A-players, pour training into them, give them growth opportunities, and build their experience using “stretch assignments.” Partner with such a superstar. Even if they get hired away by a competitor, you’ll stand a chance of moving with them.
Contrarily, if you wind up working with someone whose career is about to implode, try to get a transfer away from that person as quickly as possible.