Index: C:/xampp/htdocs/wordpress_trunk/wp-admin/includes/template.php
===================================================================
--- C:/xampp/htdocs/wordpress_trunk/wp-admin/includes/template.php	(revision 12129)
+++ C:/xampp/htdocs/wordpress_trunk/wp-admin/includes/template.php	(working copy)
@@ -1565,10 +1565,6 @@
 	$post = $global_post;
 }
 
-/*
- * display one row if the page doesn't have any children
- * otherwise, display the row and its children in subsequent rows
- */
 /**
  * {@internal Missing Short Description}}
  *
@@ -1578,15 +1574,21 @@
  * @param unknown_type $level
  */
 function display_page_row( $page, $level = 0 ) {
-	global $post;
+	global $post, $wpdb;
 	static $rowclass;
 
 	$post = $page;
 	setup_postdata($page);
 
 	if ( 0 == $level && (int)$page->post_parent > 0 ) {
-		//sent level 0 by accident, by default, or because we don't know the actual level
+		/* 
+		 * sent level 0 by accident, by default, or because we don't know the actual level
+		 * detect and fix possible loops here 
+		 */
 		$find_main_page = (int)$page->post_parent;
+	
+		$track_parents[] = $find_main_page; 
+		
 		while ( $find_main_page > 0 ) {
 			$parent = get_page($find_main_page);
 
@@ -1596,6 +1598,15 @@
 			$level++;
 			$find_main_page = (int)$parent->post_parent;
 
+			if ( in_array( $find_main_page, $track_parents ) ) {
+				$parent->post_parent = 0; 
+				$wpdb->query( $wpdb->prepare("UPDATE $wpdb->posts SET post_parent = '0' WHERE ID = %d", $parent->ID) );
+				clean_page_cache( $parent->ID );
+				break; 
+			} else {
+				$track_parents[] = $find_main_page; 
+			}
+
 			if ( !isset($parent_name) )
 				$parent_name = $parent->post_title;
 		}
