Programmatically read/change navigation history

is there a way to programmatically read/change the navigation history?
Imagine the following scenario:

  • from Page0 I swap to Page1
  • from Page1 I swap to Page2
  • the back button on Page2 should take me back to Page0: then I need to pop off the navigation stack Page1, just after swapping from Page1 to Page2.

This is only a simple example, but sometimes my needs get more complicated.

Any suggestion?

Thanks in advance