public static TreeNode fromStr(String str) {
		if (str == null) {
			return null;
		}

		String[] cs = str.substring(1, str.length() - 1).split(",");
		int n = cs.length;

		Queue<TreeNode> queue = new LinkedList<TreeNode>();
		int idx = 0;
		TreeNode root = new TreeNode(Integer.valueOf(cs[idx++]));
		queue.offer(root);
		while (!queue.isEmpty() && idx < n) {
			TreeNode node = queue.poll();
			if (idx < n) {
				String c = cs[idx++];
				if (c != "#") {
					TreeNode left = new TreeNode(Integer.valueOf(c));
					node.left = left;
					queue.offer(left);
				}
			}

			if (idx < n) {
				String c = cs[idx++];
				if (c != "#") {
					TreeNode right = new TreeNode(Integer.valueOf(c));
					node.right = right;
					queue.offer(right);
				}
			}
		}

		return root;
	}