public boolean hasPathSumI(TreeNode root, int sum) {
        if (root == null)
            return false;

        Queue<TreeNode> nodes = new LinkedList<TreeNode>();
        Queue<Integer> sums = new LinkedList<Integer>();

        nodes.add(root);
        sums.add(root.val);

        while (!nodes.isEmpty()) {
            TreeNode currNode = nodes.poll();
            int sumValue = sums.poll();

            if (currNode.left == null && currNode.right == null && sumValue == sum) {
                return true;
            }

            if (currNode.left != null) {
                nodes.add(currNode.left);
                sums.add(sumValue+currNode.left.val);
            }

            if (currNode.right != null) {
                nodes.add(currNode.right);
                sums.add(sumValue+currNode.right.val);
            }
        }
        return false;
    }