I am unable to find whats wrong in my solution ?

Actually you are returning the maximum sum eveytime and in this case tree is
1
/
2 3
/ \ /
1 3 2
/
1
after your code runs first time sum = 1 extreme left node
and after that sum will be changed to 1 and then to 3 now tree will look like
1
/
3 3
/
2now if you see it again as sum is 3 so while travesring right side of the tree sum would be returned as 3 again not 2 so it will be like
1
/
3 3
hence answer is coming as 7