public static List<SuffixTreeNode> findAllLeaves(SuffixTreeNode n){
		List<SuffixTreeNode> leaves = new ArrayList<SuffixTreeNode>();
		boolean done =false;
		LinkedList<SuffixTreeNode> queue = new LinkedList<SuffixTreeNode>();
		queue.add(n);
		while(!done){
			done = true;	
			LinkedList<SuffixTreeNode> innerQueue = new LinkedList<SuffixTreeNode>();
			while(queue.size()>0){
				SuffixTreeNode current = queue.poll();
				if(n.children.size()>0){
					for(SuffixTreeNode child: current.children){
						if(child.isLeaf){
							leaves.add(child);
						}else{
							innerQueue.add(child);
							done = false;
						}		
					}						
				}
			}
			while(innerQueue.size()>0)
				queue.add(innerQueue.poll());		
		}
		Collections.sort(leaves,new Comparator<SuffixTreeNode>(){
			public int compare(SuffixTreeNode o1, SuffixTreeNode o2) {
				return o1.start - o2.start;
			}			
		});
		return leaves;
	}