@Test
public void testReadTree() throws Exception {

  Node node1 = new CategoricalNode(rng.nextInt(), 
      new double[] { rng.nextDouble(), rng.nextDouble() }, 
      new Node[] { new Leaf(rng.nextDouble()), new Leaf(rng.nextDouble()) });
  Node node2 = new NumericalNode(rng.nextInt(), rng.nextDouble(), 
      new Leaf(rng.nextDouble()), new Leaf(rng.nextDouble()));
  
  Node root = new CategoricalNode(rng.nextInt(), 
      new double[] { rng.nextDouble(), rng.nextDouble(), rng.nextDouble() }, 
      new Node[] { node1, node2, new Leaf(rng.nextDouble()) });
  // write the node to a DataOutput
  root.write(out);
  
  // read the node back
  assertEquals(root, readNode());
}