Index: wp-includes/category.php
===================================================================
--- wp-includes/category.php	(revision 14032)
+++ wp-includes/category.php	(working copy)
@@ -209,15 +209,13 @@
 function cat_is_ancestor_of( $cat1, $cat2 ) {
 	if ( ! isset($cat1->term_id) )
 		$cat1 = &get_category( $cat1 );
-	if ( ! isset($cat2->parent) )
+	if ( ! isset($cat2->term_id) )
 		$cat2 = &get_category( $cat2 );
 
-	if ( empty($cat1->term_id) || empty($cat2->parent) )
+	if ( empty($cat1->term_id) || empty($cat2->term_id) )
 		return false;
-	if ( $cat2->parent == $cat1->term_id )
-		return true;
 
-	return cat_is_ancestor_of( $cat1, get_category( $cat2->parent ) );
+	return in_array($cat1->term_id, get_term_ancestors($cat2->term_id, 'category'));
 }
 
 
Index: wp-includes/taxonomy.php
===================================================================
--- wp-includes/taxonomy.php	(revision 14032)
+++ wp-includes/taxonomy.php	(working copy)
@@ -584,6 +584,31 @@
 }
 
 /**
+ * Get the list of all ancestors of a certain term
+ *
+ * @package WordPress
+ * @subpackage Taxonomy
+ * @since 3.1.0
+ *
+ * @uses get_terms()
+ *
+ * @param string $taxonomy Taxonomy Name
+ * @return array List of ancestor ids, from lowest to highest in the hierarchy
+ */
+function get_term_ancestors($term_id, $taxonomy) {
+	if ( !is_taxonomy_hierarchical($taxonomy) )
+		return array();
+
+	$parents = get_terms($taxonomy, array('get' => 'all', 'orderby' => 'id', 'fields' => 'id=>parent'));
+
+	$ancestors = array();
+	while ( $parents[$term_id] > 0 )
+		$term_id = $ancestors[] = $parents[$term_id];
+
+	return $ancestors;
+}
+
+/**
  * Get sanitized Term field.
  *
  * Does checks for $term, based on the $taxonomy. The function is for contextual
