private static final void cleanupNamespaceNodes(ZooKeeper zkc,String root,String selfBrokerUrl) throws Exception {
  for (  String node : zkc.getChildren(root,false)) {
    String currentPath=root + "/" + node;
    List<String> children=zkc.getChildren(currentPath,false);
    if (children.size() == 0) {
      cleanupSingleNamespaceNode(zkc,currentPath,selfBrokerUrl);
    }
 else {
      cleanupNamespaceNodes(zkc,currentPath,selfBrokerUrl);
    }
  }
}

private static final void cleanupNamespaceNodes ( ZooKeeper zkc , String root , String selfBrokerUrl ) throws Exception { for ( String node : zkc . getChildren ( root , false ) ) { String currentPath = root + "/" + node ; List < String > children = zkc . getChildren ( currentPath , false ) ; if ( children . size ( ) == 0 ) { cleanupSingleNamespaceNode ( zkc , currentPath , selfBrokerUrl ) ; } else { cleanupNamespaceNodes ( zkc , currentPath , selfBrokerUrl ) ; } } }
cleanupnamespacenodes is only called when the namespaceservice is initialized . so , no need for synchronization .
