diff --git wp-admin/includes/taxonomy.php wp-admin/includes/taxonomy.php
index 12e231a..d44de2f 100644
--- wp-admin/includes/taxonomy.php
+++ wp-admin/includes/taxonomy.php
@@ -117,7 +117,7 @@ function wp_insert_category($catarr, $wp_error = false) {
 	if ( $parent < 0 )
 		$parent = 0;
 
-	if ( empty($parent) || !category_exists( $parent ) || ($cat_ID && cat_is_ancestor_of($cat_ID, $parent) ) )
+	if ( empty( $parent ) || ! term_exists( $parent, $taxonomy ) || ( $cat_ID && term_is_ancestor_of( $cat_ID, $parent, $taxonomy ) ) )
 		$parent = 0;
 
 	$args = compact('name', 'slug', 'parent', 'description');
diff --git wp-includes/category.php wp-includes/category.php
index 4d02277..819d1f8 100644
--- wp-includes/category.php
+++ wp-includes/category.php
@@ -207,17 +207,7 @@ function get_cat_name( $cat_id ) {
  * @return bool Whether $cat2 is child of $cat1
  */
 function cat_is_ancestor_of( $cat1, $cat2 ) {
-	if ( ! isset($cat1->term_id) )
-		$cat1 = &get_category( $cat1 );
-	if ( ! isset($cat2->parent) )
-		$cat2 = &get_category( $cat2 );
-
-	if ( empty($cat1->term_id) || empty($cat2->parent) )
-		return false;
-	if ( $cat2->parent == $cat1->term_id )
-		return true;
-
-	return cat_is_ancestor_of( $cat1, get_category( $cat2->parent ) );
+	return term_is_ancestor_of( $cat1, $cat2, 'category' );
 }
 
 
diff --git wp-includes/taxonomy.php wp-includes/taxonomy.php
index 72d387a..b3fae51 100644
--- wp-includes/taxonomy.php
+++ wp-includes/taxonomy.php
@@ -1431,6 +1431,33 @@ function term_exists($term, $taxonomy = '', $parent = 0) {
 }
 
 /**
+ * Check if a term is an ancestor of another term.
+ *
+ * You can use either an id or the term object for both parameters. If you
+ * use an integer the term will be retrieved.
+ *
+ * @since 3.2.0
+ *
+ * @param int|object $term1 ID or object to check if this is the parent term.
+ * @param int|object $term2 The child term.
+ * @param string $taxonomy Taxonomy name that $term1 and $term2 belong to.
+ * @return bool Whether $term2 is child of $term1
+ */
+function term_is_ancestor_of( $term1, $term2, $taxonomy ) {
+	if ( ! isset($term1->term_id) )
+		$term1 = &get_term( $term1, $taxonomy );
+	if ( ! isset($term2->parent) )
+		$term2 = &get_term( $term2, $taxonomy );
+
+	if ( empty($term1->term_id) || empty($term2->parent) )
+		return false;
+	if ( $term2->parent == $term1->term_id )
+		return true;
+
+	return term_is_ancestor_of( $cat1, get_term( $cat2->parent, $taxonomy ) );
+}
+
+/**
  * Sanitize Term all fields.
  *
  * Relys on sanitize_term_field() to sanitize the term. The difference is that
