This question got me thinking: should we apply the principle that \"flat is better than nested\" to data as well as to code? Even when there is a \"logical tree structure\" to t
I wouldn't inherently prefer either, but rather use whatever seems best suited to the task.
If the structure is important, nesting makes life simple. If you're regularly operating over each node, the flat structure makes it easy to use for node in tree
. Of course, if you define your own class, its easy enough to abstract it so both options are simple; but it may be harder to use with external systems, such as converting to JSON.