public static String serialize(TreeNode root) {
		if (root == null)
			return "";
		StringBuilder sb = new StringBuilder();
		int numInLevel = 1, thisLevel = 1, nextLevel = 0;
		Queue<TreeNodeWrapper> queue = new LinkedList<>();
		TreeNodeWrapper rootWrapper = new TreeNodeWrapper(root, true);
		queue.add(rootWrapper);
		while (!queue.isEmpty() && thisLevel > 0) {
			for (int i = 0; i < numInLevel; i++) {
				TreeNodeWrapper cur = queue.remove();
				if (cur.isNode)
					sb.append(cur.node.val + ", ");
				else
					sb.append("#, ");
				if (cur.isNode && cur.node.left != null) {
					nextLevel++;
					queue.add(new TreeNodeWrapper(cur.node.left, true));
				} else
					queue.add(new TreeNodeWrapper(null, false));
				if (cur.isNode && cur.node.right != null) {
					nextLevel++;
					queue.add(new TreeNodeWrapper(cur.node.right, true));
				} else
					queue.add(new TreeNodeWrapper(null, false));
			}
			numInLevel *= 2;
			thisLevel = nextLevel;
			nextLevel = 0;
		}
		return sb.substring(0, sb.length() - 2);
	}