Heuristic optimization of the scanning path of particle therapy beams