public String getNodeGroup(String loc) {
    netlock.readLock().lock();
    try {
      loc = NodeBase.normalize(loc);
      Node locNode = getNode(loc);
      if (locNode instanceof InnerNodeWithNodeGroup) {
        InnerNodeWithNodeGroup node = (InnerNodeWithNodeGroup) locNode;
        if (node.isNodeGroup()) {
          return loc;
        } else if (node.isRack()) {
          // not sure the node group for a rack
          return null;
        } else {
          // may be a leaf node
          if(!(node.getNetworkLocation() == null ||
              node.getNetworkLocation().isEmpty())) {
            return getNodeGroup(node.getNetworkLocation());
          } else {
            return NodeBase.ROOT;
          }
        }
      } else {
        // not in cluster map, don't handle it
        return loc;
      }
    } finally {
      netlock.readLock().unlock();
    }
  }
@Test
  public void testNodeGroup() throws Exception {
    String res = cluster.getNodeGroup("");
    assertTrue("NodeGroup should be NodeBase.ROOT for empty location",
        res.equals(NodeBase.ROOT));
    try {
      cluster.getNodeGroup(null);
    } catch (IllegalArgumentException e) {
      assertTrue("Null Network Location should throw exception!",
          e.getMessage().contains("Network Location is null"));
    }
  }