Earlier quoted context omitted.
Check out the crazy journey Rosetta took on the way to 67P/Churyumov–Gerasimenko: https://commons.wikimedia.org/wiki/File:Animation_of_Rosetta...
Wow, I actually had no idea; how is this all pre-planned, does somebody at NASA just put "67-P/Churyumov" into a "Orbital Maneuver Planner" and let some computers crunch the possible paths out? Or does someone actually sit down and come up with the possible sequence of orbital assits (to later verify with a computer) with a pencil and paper?
There is a very interesting interview with Pablo Munoz from the Bepi Colombo team about flight dynamics on the Omega Tau podcast that explains this: http://omegataupodcast.net/295-bepicolombo/
The other interviews on the same episode are also worth listening to. In fact, the entire podcast is great.