public static TreeNode stringToTree(String source) {
        String seperator = " ";
        if (source.contains(",")) {
            seperator = ",";
        }
        String[] node = source.split(seperator);
        if (node.length == 0) {
            return null;
        }

        LinkedList<TreeNode> queue = new LinkedList<TreeNode>();
        TreeNode root = new TreeNode(Integer.valueOf(node[0]));
        queue.add(root);
        int index = 1;
        while (index < node.length) {
            TreeNode cur = queue.poll();
            if (!node[index].equals("#")) {
                TreeNode t = new TreeNode(Integer.valueOf(node[index]));
                cur.left = t;
                queue.add(t);
            } else {
                cur.left = null;
            }
            index++;
            if (index < node.length) {
                if (!node[index].equals("#")) {
                    TreeNode t = new TreeNode(Integer.valueOf(node[index]));
                    cur.right = t;
                    queue.add(t);
                } else {
                    cur.right = null;
                }
            }
            index++;
        }
        return root;

    }