Add option to hide empty root nodes
Code optimization