Task 11.1 - Simple Tree

Implement a tree data structure that can be navigated via its nodes. This means you have the root as the actual tree object, which is just represented as a Node. You can then ask any node object (incl. the root) for its children. The children of a node should be accessed by a method returning the node's first child (or null, if there is none). You should then be able to ask the child for its next sibling, and so on, to obtain the other children of the parent node (or in turn their children). To create a tree you simply create a node without parent as the root node. To insert a node you insert a sibling for the current node or add a child to the node. Most of the functionality is then actually implemented via the nodes.

Also implement a simple test framework that creates a tree, tests all the functions. Show that you can implement a pre-order and post-order traversal of the tree.

Make sure when implementing the various operations that the data structure remains a tree and an attempt to generate something else should yield an error.

The Tree.java file is attached for the initial interface to your data structure and TreeTest.java provides a test framework.