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