Index: src/wp-includes/post.php
===================================================================
--- src/wp-includes/post.php	(revision 35850)
+++ src/wp-includes/post.php	(working copy)
@@ -4122,6 +4122,10 @@
 		if ( $page->post_name == $revparts[0] ) {
 			$count = 0;
 			$p = $page;
+			/*
+			 * Loop through the given path parts from right to left,
+			 * ensuring each matches the post ancestry.
+			 */
 			while ( $p->post_parent != 0 && isset( $pages[ $p->post_parent ] ) ) {
 				$count++;
 				$parent = $pages[ $p->post_parent ];
