private static void displayCategories ( List < CategoryNode > categories , String prefix ) { for ( CategoryNode category : categories ) { System . out . printf ( "%s%s [%s]%n" , prefix , category . name , category . id ) ; displayCategories ( category . children , String . format ( "%s%s > " , prefix , category . name ) ) ; } }
Recursively prints out each category node and its children .