private R connectOne(T first, R acc, T last) {
synchronized (root) {
Connector<T, R> l = left;
if (l == null) {
return pushRight(acc, last);
}
if (l.acc == NONE) {
l.acc = acc;
l.left = first;
l.right = last;
return connectEmpty();
}
T laright = l.right;
if (mergeable.test(laright, first)) {
l.acc = combiner.apply(l.acc, acc);
l.right = last;
return connectEmpty();
}
left = null;
l.rhs = null;
l.right = none();
if (l.left != NONE) {
return pushRight(acc, last);
}
acc = pushRight(acc, last);
if (acc != NONE)
left = new Connector<>(null, acc, this);
return l.drain();
}
}