Index: wp-includes/default-filters.php
===================================================================
--- wp-includes/default-filters.php	(revision 23109)
+++ wp-includes/default-filters.php	(working copy)
@@ -127,6 +127,9 @@
 add_filter( 'wp_insert_post_parent', 'wp_check_post_hierarchy_for_loops', 10, 2 );
 add_filter( 'wp_update_term_parent', 'wp_check_term_hierarchy_for_loops', 10, 3 );
 
+// Pad terms count hierarchy loop detection
+add_filter( '_pad_term_counts_term_parent', 'wp_check_term_hierarchy_for_loops', 10, 3 );
+
 // Display filters
 add_filter( 'the_title', 'wptexturize'   );
 add_filter( 'the_title', 'convert_chars' );
Index: wp-includes/taxonomy.php
===================================================================
--- wp-includes/taxonomy.php	(revision 23109)
+++ wp-includes/taxonomy.php	(working copy)
@@ -2882,6 +2882,10 @@
 	foreach ( $term_ids as $term_id ) {
 		$child = $term_id;
 		while ( !empty( $terms_by_id[$child] ) && $parent = $terms_by_id[$child]->parent ) {
+
+		// Check $parent to see if it will cause a hierarchy loop
+		$parent = apply_filters( '_pad_term_counts_term_parent', $parent, $term_id, $taxonomy );
+
 			if ( !empty( $term_items[$term_id] ) )
 				foreach ( $term_items[$term_id] as $item_id => $touches ) {
 					$term_items[$parent][$item_id] = isset($term_items[$parent][$item_id]) ? ++$term_items[$parent][$item_id]: 1;
