ツリー構造アルゴリズム...richfaces treeから抜粋


public void addNodes(String nodeCode,TreeNode node){		
		boolean end = false;
		int counter = 1;
		while(!end){
			String code = nodeCode != null ? nodeCode + "." + counter : String.valueOf(counter);
			
			Node nodes = nodeDao.query(code);
			if(nodes!=null){
				System.out.println(code);
				TreeNodeImpl nodeImpl = new TreeNodeImpl();
				nodeImpl.setData(nodes);
				node.addChild(new Integer(counter), nodeImpl);
				addNodes(code,nodeImpl);
				counter++;
			}else{
				end = true;
			}
			
		}
	}