Index: includes/webform.components.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/webform/includes/webform.components.inc,v
retrieving revision 1.25.2.25
diff -u -r1.25.2.25 webform.components.inc
--- includes/webform.components.inc	19 Oct 2010 04:58:08 -0000	1.25.2.25
+++ includes/webform.components.inc	20 Oct 2010 02:34:29 -0000
@@ -805,6 +805,20 @@
     }
   }
 
+  // Remove groups that do not have any children.
+  $previous_cid = 0;
+  foreach ($options as $cid => $label) {
+    if (isset($node->webform['components'][$previous_cid]['type']) && webform_component_feature($node->webform['components'][$previous_cid]['type'], 'group') && webform_component_feature($node->webform['components'][$cid]['type'], 'group')) {
+      unset($options[$cid]);
+    }
+  }
+
+  // Remove the last item from the list if it's a group.
+  if (webform_component_feature($node->webform['components'][$cid]['type'], 'group')) {
+    unset($options[$cid]);
+  }
+
+  // Convert page breaks into optgroups.
   if ($optgroups) {
     $grouped_options = $options;
     $options = array();
