public void toJson(String filename) {
        PrintWriter writer = null;
        
        try {
            Gson gson = new GsonBuilder().
                setPrettyPrinting().
                registerTypeHierarchyAdapter(
                    BlockNode.class, 
                    new BlockNode.BlockNodeAdapter()).
                create();
            writer = new PrintWriter(filename);
            gson.toJson(parseTree, writer);
        } catch(java.io.IOException ex) {
//            ex.printStackTrace();
        } finally {
            writer.flush();
            writer.close();
        }
    }