Ionic 4 navigation stack

Is there a way to modify the navigation stack of the application?

To be precise, if the current navigation state is
Page 1 --> Page 2 --> Page 3 --> Page 4

I want to remove Page 2 and Page 3 and modify the state to
Page 1 --> Page 4