public static List<Integer> binaryTreePreorder(TreeNode root){
		
		ArrayList<Integer> result = new ArrayList<Integer>();
		Stack<TreeNode> nodes = new Stack<TreeNode>();
		
		if(root==null)
			return result;
		
		nodes.push(root);
		
		while(!nodes.isEmpty()){
			TreeNode tem = nodes.pop();
			result.add(tem.val);
			
			if(tem.right!=null){
				nodes.push(tem.right);
			}
			
			if(tem.left!=null){
				nodes.push(tem.left);
			}
			
		}
		
		
		return result;
		
	}