diff -u b/addressfield.module b/addressfield.module --- b/addressfield.module +++ b/addressfield.module @@ -398,6 +398,9 @@ if (element_children($element[$ckey])) { // Add the child onto the stack for processing its children. $stack[$ckey] = &$element[$ckey]; + // Move pointer of the stack to the next element. + next($stack); + // Make the child the current element. $element = &$element[$ckey]; reset($element); @@ -412,6 +415,8 @@ else { // Remove the current element from the stack. array_pop($stack); + // Make sure the pointer is always at the end of the stack + end($stack); // If there are still elements on the stack. if (!empty($stack)) {