I realize this comment is about the original code, but the test for WT_PAGE_IS_ROOT makes no sense to me: this page came from a WT_REF structure, which means it can't possibly be root?   I think this dates from a previous version (IIRC, there were versions where the root page did have a WT_REF structure), I'd suggest simplifying to assert that page isn't NULL.