Index: src/wp-admin/includes/template.php
===================================================================
--- src/wp-admin/includes/template.php	(revision 31675)
+++ src/wp-admin/includes/template.php	(working copy)
@@ -240,12 +240,48 @@
 
 		foreach( $keys as $k ) {
 			if ( in_array( $categories[$k]->term_id, $args['selected_cats'] ) ) {
-				$checked_categories[] = $categories[$k];
+				$checked_categories[$categories[$k]->term_id] = $categories[$k];
 				unset( $categories[$k] );
 			}
 		}
 
-		// Put checked cats on top
+		// Add the full hierarchy of the checked categories
+		foreach ( $checked_categories as $cat ) {
+			// Get the checked category ancestor
+			$cat_parent = $cat;
+			while ( $cat_parent->parent != 0 ) {	
+				$cat_parent = get_term_by( 'id', $cat_parent->parent, $taxonomy );
+			}
+
+			// Include the ancestor
+			if ( ! array_key_exists( $cat_parent->term_id, $checked_categories ) ) {
+				$checked_categories[$cat_parent->term_id] = $cat_parent;
+			}
+
+			// Include the children categories of the ancestor
+			$children_cats = get_terms( $taxonomy, array(
+				'child_of' => $cat_parent->term_id,
+				'fields' => 'ids',
+				'hide_empty' => 0,
+			) );
+			if ( $children_cats ) {
+				foreach ( $children_cats as $child_cat_id ) {
+					$child_cat = get_term_by( 'id', $child_cat_id, $taxonomy );
+					if ( ! array_key_exists( $child_cat->term_id, $checked_categories ) ) {
+						$checked_categories[$child_cat->term_id] = $child_cat;
+					}
+				}
+			}
+		}
+
+		// Unset the newly found categories to avoid duplication
+		foreach ( $categories as $key => $category ) {
+			if ( array_key_exists( $category->term_id, $checked_categories ) ) {
+				unset( $categories[$key] );
+			}
+		}
+
+		// Put checked cats and their hierarchy on top
 		echo call_user_func_array( array( $walker, 'walk' ), array( $checked_categories, 0, $args ) );
 	}
 	// Then the rest of them
