public int sumNumbers(TreeNode root) {
        int sum = 0;
        TreeNode nowNode = root;
        Stack<TreeNode> nodeStack = new Stack<TreeNode>();
        boolean popNode = false;

        while (!(nowNode==root && popNode)) {
            if (!popNode) {
                if (nowNode != null) {
                    nodeStack.push(nowNode);
                    nowNode = nowNode.left;
                } else {
                    popNode = true;
                }
            } else {
                TreeNode topNode = nodeStack.peek();
                if (nowNode == topNode.right) {
                    if (nowNode != null && nowNode.left==null && nowNode.right==null) {
                        sum += getNumber(nodeStack);
                    }
                    nowNode = nodeStack.pop();
                } else {
                    nowNode = topNode.right;
                    popNode = false;
                }
            }
        }

        return sum;
    }