+/** <font color=blue>a tree (or node in a tree); see jargon.txt for details</font> */
+public class Tree<T>
+ extends PrintableTree<Tree<T>>
+ implements Iterable<Tree<T>>,
+ GraphViz.ToGraphViz {
+
+ private final Input.Region location;
+ private final T head;
+ private final Tree<T>[] children;
+ private final boolean lift;
+
+ /** the element at the head of the tree */
+ public T head() { return head; }
+
+ private Tree<T> lifted() { return children[children.length-1]; }
+
+ /** the number of children the tree has */
+ public int numChildren() {
+ return lift
+ ? (children.length-1)+lifted().numChildren()
+ : children.length;
+ }
+
+ /** the tree's children */
+ public Iterable<Tree<T>> children() { return this; }
+
+ /** the tree's children */
+ public Iterator<Tree<T>> iterator() {
+ return lift
+ ? new ConcatenateIterator(new ArrayIterator(children, 0, children.length-1),
+ children[children.length-1].iterator())
+ : new ArrayIterator(children);
+ }