--- og_hierarchy/og_hierarchy.module	2005-08-04 16:19:33.966024382 -0700
+++ og_hierarchy_modified/og_hierarchy.module	2005-08-04 16:21:22.659697060 -0700
@@ -78,7 +78,8 @@
     case 'validate':
       if ($node->type == 'og') {
          $group = og_hierarchy_get_group_by_name(trim($node->title));
-         if ((isset($node->nid) && count($group) > 1) || (!isset($node->nid) && count($group) >= 1)) {
+         if ((isset($node->nid) && count($group) > 1) || 
+	     $group && (!isset($node->nid) && count($group) >= 1)) {
            form_set_error('title', t('There already is a group with the name %title. This will cause unexpected results with the og_hierarchy module.', array('%title' => theme('placeholder', trim($node->title)))));
          }
       }
@@ -198,13 +199,13 @@
     $children = array();
     $result = db_query('SELECT o.*, h.parent, n.title FROM {og} o LEFT JOIN {og_hierarchy} h ON o.nid = h.nid INNER JOIN {node} n ON o.nid = n.nid ORDER BY n.title');
     while ($term = db_fetch_object($result)) {
-print_r($term);
+      //print_r($term);
       $children[$term->parent][] = $term->nid;
       $parents[$term->nid][] = $term->parent;
       $terms[$term->nid] = $term;
     }
   }
-print_r($children[$parent]);
+  //print_r($children[$parent]);
   $max_depth = (is_null($max_depth)) ? count($children) : $max_depth;
   if (isset($children[$parent])) {
     foreach ($children[$parent] as $child) {
@@ -229,7 +230,7 @@
 * Get group node ID by group name.
 */
 function og_hierarchy_get_group_by_name($name) {
-  $result = db_query("SELECT nid, title FROM node WHERE title = '%s'", $name);
+  $result = db_query("SELECT nid, title FROM {node} WHERE title = '%s'", $name);
   if (db_num_rows($result)) {
     $group = array();
     while ($node = db_fetch_object($result)) {
