--- nat.module_orig	2009-02-15 22:14:48.000000000 +0000
+++ nat.module	2009-02-17 14:36:20.000000000 +0000
@@ -248,6 +248,12 @@ function nat_settings_form() {
       '#default_value' => isset($nat_config['node_links'][$type]) ? $nat_config['node_links'][$type] : 0,
       '#parents' => array('node_links', $type)
     );
+    $form['nat_'. $type]['duplicate_terms_'. $type] = array(
+      '#type' => 'checkbox',
+      '#title' => t('Allow duplicate terms to be created.'),
+      '#default_value' => isset($nat_config['duplicate_terms'][$type]) ? $nat_config['duplicate_terms'][$type] : 0,
+      '#parents' => array('duplicate_terms', $type)
+    );
   }
   $form['submit'] = array('#type' => 'submit', '#value' => t('Save configuration'));
 
@@ -264,8 +270,9 @@ function nat_settings_form_submit($form,
 
   $form_values['body'] = array_filter($form_values['body']);
   $form_values['delete'] = array_filter($form_values['delete']);
-  $form_values['node_links'] = array_filter($form_values['node_links']);
   $form_values['related'] = array_filter($form_values['related']);
+  $form_values['node_links'] = array_filter($form_values['node_links']);
+  $form_values['duplicate_terms'] = array_filter($form_values['duplicate_terms']);
 
   variable_set('nat_config', $form_values);
 
@@ -570,6 +577,18 @@ function _nat_get_vocabularies() {
  *   An array of term objects.
  */
 function _nat_add_terms($vids, $title, $body, $hierarchy = array(), $relations = array(), $synonyms = NULL) {
+  $nat_config = _nat_variable_get();
+  $types = node_get_types();
+  $term = taxonomy_get_term_by_name($title);
+
+  foreach ($types as $type => $type_object) {
+    if ($nat_config['duplicate_terms'][$type] == $type) {
+      if (array_search($term[0]->vid, $vids)) {
+        return array();
+      }
+    }
+  }
+
   $edit = array(
     'name' => $title,
     'description' => $body,
@@ -727,7 +746,8 @@ function _nat_variable_get($name = NULL)
       'body' => array(),
       'delete' => array(),
       'related' => array(),
-      'node_links' => array()
+      'node_links' => array(),
+      'duplicate_terms' => array(),
     );
     $variables = variable_get('nat_config', array());
     $variables = array_merge($defaults, $variables);