private void pathSumHelper(TreeNode root, int sum, ArrayList<Integer> solution, ArrayList<ArrayList<Integer>> result)
    {
        if (root.left == null && root.right == null) {
            if (root.val == sum) {
                solution.add(root.val);
                result.add(new ArrayList<Integer>(solution));
                solution.remove(solution.size() - 1);
            }
        }
        if (root.left != null && sum >= root.left.val) {
            pathSumHelper(root, sum - root.left.val, solution, result);
        }
        if (root.right != null && sum >= root.right.val) {
            pathSumHelper(root, sum - root.right.val, solution, result);
        }
    }