public List<Integer> preorderTraversal(TreeNode root) {

        LinkedList<TreeNode> temp = new LinkedList<TreeNode>();
        LinkedList<TreeNode> rResult = new LinkedList<TreeNode>();		// reverse result
        List<Integer> result = new ArrayList<Integer>();
        if (root == null)
            return result;
        temp.add(root);
        while (temp.size() != 0) {
            TreeNode node = temp.pop();
            rResult.add(node);
            if (node.right != null) {
                TreeNode nodeR = node.right;
                temp.push(nodeR);
            }
            if (node.left != null) {
                TreeNode nodeL = node.left;
                temp.push(nodeL);
            }

        }
        while (0 != rResult.size()) {
            result.add(rResult.removeFirst().val);
        }

        return result;
	}