great tree recursion problem