public static boolean isValidSerialization(String preorder) {
		Stack<String> stack = new Stack<>();
		Stack<String> stack2 = new Stack<>();
		String items[] = preorder.split(",");
		for (int i = 0; i < items.length; i++) {
			stack.push(items[i]);
		}
		if (stack.size() == 1)
			return stack.pop().equals("#") ? true : false;
		if (stack.size() == 2)
			return false;
		while (!stack.isEmpty()) {
			if (stack.peek().equals("#")) {
				stack.pop();
				stack2.push("#");
			} else {
				if (stack2.isEmpty())
					return false;
				stack2.pop();
				if (stack2.isEmpty())
					return false;
				stack2.pop();
				stack.pop();
				stack2.push("#");
			}
		}
		return stack2.isEmpty() ? false : true;
	}