diff --git a/mappers/taxonomy.inc b/mappers/taxonomy.inc
index 1d03cce..0960247 100644
--- a/mappers/taxonomy.inc
+++ b/mappers/taxonomy.inc
@@ -83,9 +83,7 @@ function taxonomy_feeds_set_target($source, $entity, $target, $terms) {
 
   $i = 0;
   $entity->$target = isset($entity->$target) ? $entity->$target : array();
-  while ($i < count($terms)) {
-    $term = $terms[$i];
-
+  foreach ($terms as $term) {
     $tid = 0;
     if ($term instanceof FeedsTermElement) {
       $tid = $term->tid;
@@ -97,18 +95,21 @@ function taxonomy_feeds_set_target($source, $entity, $target, $terms) {
       // @Todo figure out how to make 'Overig' a setting
       $tid = taxonomy_term_check_term($term, $vocabulary->vid, 'Overig');
     }
-
-    // Support for hierarchical terms.
-    $term_parents = taxonomy_get_parents_all($tid);
-    if (!empty($term_parents)) {
-      array_shift($term_parents);
-      foreach ($term_parents as $term_parent) {
-        array_push($terms, $term_parent->tid);
+    if ($tid) {
+      $tids = array($tid);
+      // Support for hierarchical terms.
+      $term_parents = taxonomy_get_parents_all($tid);
+      if (!empty($term_parents)) {
+        array_shift($term_parents);
+        foreach ($term_parents as $term_parent) {
+          array_unshift($tids, $term_parent->tid);
+         }
       }
-    }
 
-    if ($tid) {
-      $entity->{$target}['und'][$i]['tid'] = $tid;
+      foreach ($tids as $tid) {
+        $entity->{$target}['und'][$i]['tid'] = $tid;
+        $i++;
+      }
     }
 
     if ($info['cardinality'] == 1) {
