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:

masterpage
-page1
—page1-1
—test
—page1-3
-page2
—page2-1
—page2-2
-page3
-test
-page5
-page6

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 - Pastebin.com](http://pastebin.com/AM94eK3m)

Thanks,
Tom

Fixed: I was just missing some returns.

It’s always the little things…