Index: comment.php
===================================================================
--- comment.php	(revision 37058)
+++ comment.php	(working copy)
@@ -2151,7 +2151,34 @@
 	$new = apply_filters( 'pre_wp_update_comment_count_now', null, $old, $post_id );
 
 	if ( is_null( $new ) ) {
-		$new = (int) $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_approved = '1'", $post_id ) );
+
+		$_bad_parents = $bad_parents = array();
+		$depth = $_depth = get_option('thread_comments_depth', 5);
+
+		while ($depth > 1) {
+
+			if ($_depth == $depth) {
+				$depth--;
+				$clause = " AND comment_approved != '1'";
+			} else {
+				$depth--;
+				if ($_bad_parents != $bad_parents) {
+					$_bad_parents = $bad_parents;
+				} else {
+					continue;
+				}
+
+				$clause = ' AND comment_parent IN ('.implode(',', $bad_parents).')';
+			}
+
+			$bad_parents = array_merge($bad_parents, $wpdb->get_col("SELECT comment_ID FROM $wpdb->comments WHERE comment_post_ID = $post_id.$clause"));
+			$bad_parents = array_unique($bad_parents);
+		}
+
+
+		$bad_parents = implode(',', $bad_parents);
+
+		$new = (int) $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_approved = '1' AND comment_parent NOT IN ($bad_parents)", $post_id ) );
 	} else {
 		$new = (int) $new;
 	}
