solution to isSameTree