cbolt's solution worked well for me. I made two minor edits...
PreviousPage function would fail if Children return a dataobjectset with no children. So updated the function to use Count():
function PreviousPage() {
$where = "ParentID = {$this->ParentID} AND Sort < {$this->Sort}";
$pages = DataObject::get("SiteTree", $where, "Sort DESC", "", 1);
if($pages) {
foreach($pages as $page) {
// if page has a child go to the last child page
$children = $page->AllChildren();
if ($children->Count()) {
foreach ($children as $child) {
continue;
}
return $child;
}
return $page;
}
}
I also updated both functions Where clauses to only return pages shown in the menu. ie:
$where = "ParentID = $parent AND `SiteTree`.ID != 4 AND Sort > $sort AND ShowInMenus = 1";