I would like to plot a "decomposition tree" in Mathematica.
I have a function f that takes an object and returns all the components of that object as a list. For the purpose of this question, let's just decompose Mathematica expressions as follows (my actual f relies on an external database to decompose different kinds of objects, so I can't easily post it):
f[e_?AtomQ] := {}
f[e_] := List @@ e
I would like to create a tree plot that shows how an object is decomposed as we recursively keep applying f. For the particular example f above, we should get something very similar to the output of TreeForm, except that a full expression should be displayed (rather than just a head) at each node. The children of a node are going to be its components as returned by f.
Note that elements can repeat in a decomposition tree like this, but not elements are repeated in the output of TreePlot as it works with graphs. One idea would be to generate a unique "internal name" for each node, construct a graph, and use TreePlot, setting it to display the actual form of the nodes rather than their "internal name"


