public static boolean hasPathSum(TreeNode root, int sum) {//AC!
        if (root == null) return false;
        if (root.left == null && root.right == null) {//leaf
            if (root.val == sum) return true;
            else return false;
        }
        return hasPathSum(root.left, sum-root.val) || hasPathSum(root.right, sum-root.val);
    }