In this line you are passing an element of the array "get_tree $new_children $element $p($level) $level" when you want to pass the whole array. "get_tree $new_children $element $p $level"
I think.