+
+ public Tree<T> expand1() throws Ambiguous {
+ if (hp.size() > 1) {
+ HashSet<Forest<T>> hf0 = new HashSet<Forest<T>>();
+ Iterator<Forest<T>> ih = hp.iterator();
+ ih.next().gather(hf0);
+ for(Forest<T> f : hp) {
+ HashSet<Forest<T>> hf1 = new HashSet<Forest<T>>();
+ f.gather(hf1);
+ hf0.retainAll(hf1);
+ }
+ HashSet<Tree<T>> ht = new HashSet<Tree<T>>();
+ expand(ht, hf0, new Tree(null, "*"));
+ throw new Ambiguous((Forest<?>)this,
+ (HashSet<Tree<?>>)(Object)ht);
+ }
+ return hp.iterator().next().expand1();
+ }
+
+ public void gather(HashSet<Forest<T>> ht) {
+ ht.add(this);
+ for(Forest<T> f : hp) f.gather(ht);
+ }
+
+ public Forest resolve() { return this; }
+ public void expand(HashSet<Tree<T>> ht, HashSet<Forest<T>> ignore, Tree<T> bogus) {
+ if (ignore.contains(this)) { ht.add(bogus); return; }
+ for (Forest<T> f : hp) f.expand(ht, ignore, bogus);
+ }
+ public boolean contains(Forest f) { return hp.contains(f); }