Class not quite working as planned... Help!

Hi all,

I’m creating a class which searches for a certain subpage of whichever page the user is on. If it can’t find the subpage, it should ‘go up a level’ in the navigation tree and see if the page is there.

For example:

If I am looking for a subpage called ‘test’, and the navigation was as follows:


Scenario a: If I am on page 1: ‘test’ will be found straight away.
Scenario b: If I am on page 2: There is no subpage called ‘test’, so go up a level to ‘masterpage’ and check there. Here we find a subpage called ‘test’.

I hope this is clear. At the moment scenario A works fine, but scenario B returns nothing.

Here is my code:

 Failing class -](


Fixed: I was just missing some returns.

It’s always the little things…