If we are on 3rd level of page that time we need root page id of current page then following script will help you more.
you will get root page id of current page
Id you want to root page title then you may use following script
If you want all the level of the page tree then you will get array all array from following script
Simply print the following function you will get all level of page tree
I hope it will work for you and make your day 😉
If you have any queries, please do not hesitate to contact me at Jainish Senjaliya