Index: nat.module
===================================================================
RCS file: /cvs/drupal/contributions/modules/nat/nat.module,v
retrieving revision 1.14.2.15
diff -u -p -r1.14.2.15 nat.module
--- nat.module	30 Jun 2007 13:58:45 -0000	1.14.2.15
+++ nat.module	1 Nov 2007 03:24:46 -0000
@@ -482,14 +482,16 @@ function _nat_get_vocabularies() {
  *
  * @param $vids
  *   An array of vocabulary IDs denoting the vocabularies into which a NAT term
- * is to be added.
+ *   is to be added.
  * @param $title
  *   Node title.
  * @param $body
  *   Node body.
  * @param $hierarchy
- *   The taxonomy array for the node in question. This is used to, if set,
- * insert the new term as a child term of the selected parent.
+ *   The taxonomy form values for the node in question. This array is keyed with
+ *   vocab IDs and contains array values of term IDs. This is used to, if set,
+ *   insert the new term as a child term of the selected parent.
+ *
  * @return $tids
  *   An array of term objects.
  */
@@ -541,8 +543,9 @@ function _nat_add_terms($vids, $title, $
  * @param $body
  *   Body of the node.
  * @param $hierarchy
- *   The taxonomy array for the node in question. This is used to, if set,
- * insert the new term as a child term of the selected parent.
+ *   The taxonomy array for the node in question. The keys are term IDs in this case as
+ *   opposed to the insert's $node->taxonomy which uses taxonomy vocab ID as a key.
+ *   This is used to, if set, insert the new term as a child term of the selected parent.
  */
 function _nat_update_terms($terms, $title, $body, $hierarchy, $relations = array(), $synonyms = null) {
   $edit = array(
@@ -556,11 +559,15 @@ function _nat_update_terms($terms, $titl
   }
 
   foreach ($terms as $term) {
-    if (isset($hierarchy[$term->vid])) {
-      $edit['parent'] = $hierarchy[$term->vid];
-    }
-    else {
-      $edit['parent'] = array();
+
+    $edit['parent'] = array();
+    if (is_array($hierarchy)) {
+      foreach ($hierarchy as $tid => $parent) {
+        if ($parent->vid == $term->vid) {
+          $edit['parent'] = $parent->tid;
+          break;
+        }
+      }
     }
 
     if (count($relations)) {
