Tree parent = parents.get(enclosingS0); // cannot be root
while (spansEqual(parent, enclosingS0)) { // in case we had missed unary transitions
enclosingS0 = parent;
parent = parents.get(parent);
}
if (parent.children()[0] == enclosingS0) { // S0 is the left child of the correct tree
return new OracleTransition(new ShiftTransition(), false, false, false);
}
// was the second (right) child. there must be something else on the stack...
Tree S1 = state.stack.pop().peek();
Tree enclosingS1 = getEnclosingTree(S1, parents, leaves);