ExhibitBuilder 3.1 next page nav function code question

I'm writing some custom functions to skip blank pages when generating navigation links. So I'm copying and modifying the previous/next link functions into our theme. The code in the plugin's link to next page function includes this

if ($nextPage = $exhibitPage->firstChildOrNext()) {
        $targetPage = $nextPage;
    } elseif ($exhibitPage->parent_id) {
        $parentPage = $exhibitPage->getParent();
        $nextParentPage = $parentPage->next();
        if ($nextParentPage) {
            $targetPage = $nextPage;

Is there a reason for setting the targetPage to nextPage after checking for a valid nextParentPage? It just doesn't look right to me. It seems that you'd want to set targetPage to nextParentPage after identifying that it exists.

You're right: that code obviously looks wrong.

In fact, though, it's a little more wrong than it appears to be.

What firstChildOrNext() actually does is this: If there are child pages, return the first child; if there is a next pages on the current level, return that one; and if there's neither of those first two, return the next page of the parent.

So, basically, the else in the code you posted never actually comes into play, I think.

The just-released version of Exhibit Builder should restore some sanity to that section of the code, as well as fix some problems that would happen when there was a jump of more than one page level between the previous and next pages.