Question: Extracting all operands from an expression

I'm looking to create a procedure,Inside:=proc(expr), in maple that takes an expression and will return a direct graph of all the elements,including the operands,of that expression.

For instance for x+2*y*z^2 the output should be (in a graph form not a tree)

                           +
                        /    \
                       /      \
                      x        *
                           /   |  \
                          /    |   \
                        2      y   ^
                                  /   \
                                 /     \
                                z       2
and [1,2,3,4] should return
       
        list
      / | | \
     1  2 3 4

My initial reasoning was to extract and create a list of all the elements from the expression and plot them(somehow) in the graph .
I've tried using the 'op' function for the first part however I don't know how to 'exhaust' the expression until there isn't any element left to add to the list .The 'map' function doesn't seem to work so well either .Also I'm not sure on how to plot the graph in such a way that will correspond with he above tree examples.

Any guidance will be great.Thank you
    

 

Please Wait...