refactored internal structure, output is a hierarchical tree of boxes and their data