Filter Particle Tracks by number of collisions

Hello,

I am trying to plot particle tracks however I would like to only capture a certain number of collisions rather than just until the particle is terminated. Is there any way to do this?

Thanks