title: Program to generate recursion tree for generic recursive program
body: <p>Often when solving a recursive or dynamic programming problem, I find myself drawing a recursion tree to help simplify the question for me. However, for some questions which are complicated I have access to the solution but no idea how to draw the tree. </p>
  
  <p>What I have tried so far is printing out the calling function and it's parameters, and this has proved helpful in some examples. However, I saw this tree for fibonacci(5) here generated by mathematica in this answer: <a href="https://mathematica.stackexchange.com/questions/116344/how-do-i-create-a-recursive-tree-plot-for-the-fibonacci-sequence">https://mathematica.stackexchange.com/questions/116344/how-do-i-create-a-recursive-tree-plot-for-the-fibonacci-sequence</a></p>
  
  <p><a href="https://i.stack.imgur.com/zmshy.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zmshy.png" alt="enter image description here"></a></p>
  
  <p>I was wondering if I could generate the same kind of tree in a mainstream high level language like Python, Java, or C++? The tree could just have the nodes as the function name and parameters like in the image. </p>