--- taxonomy.module.orig	2008-01-28 00:55:15.000000000 +0700
+++ taxonomy.module	2008-03-30 00:49:31.000000000 +0700
@@ -304,6 +304,10 @@ function taxonomy_save_term(&$form_value
   );
 
   if (!empty($form_values['tid']) && $form_values['name']) {
+    // Check if updating the term will create duplicated terms
+    if (db_result(db_query("SELECT COUNT(t.tid) FROM {term_data} t INNER JOIN {term_hierarchy} h ON t.tid = h.tid WHERE t.name = '%s' AND h.parent = '%d' AND t.tid != '%d'", $form_values['name'], $form_values['parent'], $form_values['tid'])) > 0) {
+      return NOT_SAVED_UPDATED;
+    }
     drupal_write_record('term_data', $form_values, 'tid');
     $hook = 'update';
     $status = SAVED_UPDATED;
@@ -312,6 +316,10 @@ function taxonomy_save_term(&$form_value
     return taxonomy_del_term($form_values['tid']);
   }
   else {
+    // Check if creating the term will create duplicated terms
+    if (db_result(db_query("SELECT COUNT(t.tid) FROM {term_data} t INNER JOIN {term_hierarchy} h ON t.tid = h.tid WHERE t.name = '%s' AND h.parent = '%d'", $form_values['name'], $form_values['parent']) ) > 0) {
+      return NOT_SAVED_NEW;
+    }
     drupal_write_record('term_data', $form_values);
     $hook = 'insert';
     $status = SAVED_NEW;
