diff --git a/hierarchical_select.module b/hierarchical_select.module
index 731267d..88bc29d 100644
--- a/hierarchical_select.module
+++ b/hierarchical_select.module
@@ -2116,7 +2116,7 @@ function _hierarchical_select_dropbox_reconstruct_lineages_save_lineage_enabled(
 
       $child_added_to_lineage = FALSE;
       foreach (array_keys($children) as $child) {
-        if (in_array($child, $selection)) {
+        if (in_array((string)$child, $selection)) {
           if (!$child_added_to_lineage) {
             // Add the child to the lineage.
             $lineages[$id][$level + 1] = array('value' => $child, 'label' => $children[$child]);
