public class TreeNode { public enum Color {red, black} private T item; private TreeNode leftChild; private TreeNode rightChild; private TreeNode parent; private Color color; public TreeNode(T newItem) { // Initializes tree node with item and no children. item = newItem; leftChild = null; rightChild = null; parent = null; color = Color.red; } // end constructor public TreeNode(T newItem, TreeNode left, TreeNode right, Color col) { // Initializes tree node with item and // the left and right children references. item = newItem; leftChild = left; rightChild = right; parent = null; color = col; } // end constructor public T getItem() { // Returns the item field. return item; } // end getItem public void setItem(T newItem) { // Sets the item field to the new value newItem. item = newItem; } // end setItem public TreeNode getLeft() { // Returns the reference to the left child. return leftChild; } // end getLeft public void setLeft(TreeNode left) { // Sets the left child reference to left. leftChild = left; } // end setLeft public TreeNode getRight() { // Returns the reference to the right child. return rightChild; } // end getRight public void setRight(TreeNode right) { // Sets the right child reference to right. rightChild = right; } // end setRight public TreeNode getParent() { // Returns the reference to the right child. return parent; } // end getRight public void setParent(TreeNode newParent) { // Sets the right child reference to right. parent = newParent; } // end setRight public Color getColor() { // Returns the color of the node return color; } public void setColor(Color newColor) { // Sets the color of the node color = newColor; } } // end TreeNode