Simplify hasPathSum implementation by unifying many edge cases.