code: public static SectionContainer eliminateEmptyStructures( SectionContainer sc ){
  
  		for( int i=sc.nrOfSubSections()-1; i>=0; i-- ){
  			Section ss = sc.getSubSection( i );
  			
  			if( ss.getClass() == SectionContainer.class ){
  				SectionContainer sci = (SectionContainer)ss;
  				eliminateEmptyStructures( sci );			
  			}
  			else if( ss.getClass() == SectionContent.class )
  				eliminateEmptyStructures( (SectionContent)ss );
  
  			if( ss.empty() ) sc.removeSection(ss);
  		}
  		
  		//encapsulating Sections
  		if( sc.nrOfSubSections()==1 && sc.getSubSection(0).getClass()==SectionContainer.class ){
  			SectionContainer sc0 = (SectionContainer)sc.getSubSection( 0 );
  			if( sc0.getTitleElement()==null ){
  				sc.removeSection( sc0 );
  				for( int i=0; i<sc0.nrOfSubSections(); i++)
  					sc.addSection( sc0.getSubSection(i) );
  			}
  		}	
  		
  		return sc;
  	}
docs: Removes all empty Structures from a SectionContainer and all substructures.