fix issue 9783: fix tree time when profiling recursive functions

The tree time should only accumulate for the top level call of recursive function calls.