class BinaryTreeSerialization {

  public BinaryNode<Integer> deserialize(String tree) {
    validateInput(tree);

    if (index >= tree.length()) {
      return null;
    } else {
      char currentChar = tree.charAt(index);
      if (currentChar == '#') {
        index++;
        return null;
      } else {
        BinaryNode<Integer> node = new BinaryNode<Integer>(currentChar - 48);
        index++;
        node.setLeft(deserialize(tree));
        node.setRight(deserialize(tree));
        return node;
      }
    }
  }

  public  BinaryTreeSerialization();

}