//tree node with any amount of sons
public class TreeNode{
      public String node_content;
      public TreeNode[] sons;
      public int number_sons;   
      public boolean is_endnode;
	
       //usual Constructor
      public TreeNode(){;}	

      //Constructor with two arguments
      public TreeNode(String node_content, TreeNode[]  sons){
	     this.node_content=node_content;
	     this.sons=sons;
	     int i;
	     for(i=0; sons[i]!=null; i++) {}
	     this.number_sons = i;
      }			
           
      //Constructor for node without sons
      public TreeNode(String node_content){
	     this.node_content=node_content;             
             this.sons=null;
	     this.number_sons=0;
      }			

      //Functions for the separate putting and getting of elements  	
      public String get_node() {
		return node_content;
      }		      	

      public TreeNode[] get_sons(){
		return sons;
      }		      	

      //Functions for the separate putting and getting of elements  	
      public void put_node_content(String node_content) {
		this.node_content=node_content;
      }		      	

//adds the sons, but be aware that the tail of the array may
//contain no sons, i.e. pointers to null
      public void put_sons(TreeNode[] sons){
		this.sons = sons;
		int i;
		for(i=0; sons[i]!=null; i++) {}
		this.number_sons = i;
      }		      	

      public void delete_sons(){
                this.sons = null;
		this.number_sons = 0;
      }

     public String toString(){
            String content="node content: "+node_content;             
            String sons_content="";

            if(sons == null){
               sons_content+=""; 
            }else{
               int i=0;
               while(sons[i] != null){
                     sons_content+="son "+i+":"+"node content - "+
			sons[i].node_content+
			" is_endnode="+sons[i].is_endnode+"\n";
                     i++;
               }
            }
            return content+"  is_endnode="+is_endnode
		+"   "+this.number_sons+" son(s)\n"+sons_content;
      }
}