stanfordnlp/CoreNLP · error · IllegalStateException
node is not parent's left or right child!!!
Error message
node is not parent's left or right child!!!
What it means
While validating ordering, check() walks from a node up through n.parent and asserts n is either n.parent.left or n.parent.right. If it is neither, this IllegalStateException fires: the node is unreachable as a proper child of its claimed parent, i.e. the tree's parent/child links are torn. This is a catch-all corruption detector in the validator, thrown as an internal invariant failure.
Solutions
- Rebuild the IntervalTree from scratch and re-insert all intervals.
- Never modify TreeNode parent/left/right pointers outside the library's own algorithms.
- Serialize all access to the tree (no internal thread safety) to avoid interleaved structural updates.
- Capture a minimal insert/remove/rotate sequence and report it to Stanford CoreNLP if reproducible via public API.
Defensive patterns
Strategy: try-catch
Validate before calling
try {
tree.check(tree.root);
} catch (IllegalStateException e) {
// ancestry chain broken -> rebuild from source intervals
} Try / catch
try {
intervalTree.remove(iv, v);
intervalTree.check(intervalTree.root);
} catch (IllegalStateException e) {
intervalTree = rebuildTree(intervals);
} Prevention
- Never store and re-use TreeNode references across tree mutations.
- Confine the tree to one thread or synchronize all access.
- Rebuild from the canonical interval list whenever any invariant check fails.
- Include randomized insert/remove + check() tests in CI to surface corruption early.
When it happens
Trigger: check() (or balance()/rotateUp()) climbs an ancestry chain and reaches a node whose parent pointer exists but whose parent's left/right fields don't include it — after a rotation spliced pointers incorrectly or a remove left a phantom parent link.
Common situations: Hit during CoreNLP interval-tree debugging after failed rotations; after concurrent unsynchronized insert/remove; after external code or custom subclasses re-linking nodes.
Understand the failure class
Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.
Related errors
- node left parent is not same as node!!!
- node right parent is not same as node!!!
- Empty node shouldn't have left branch
- Empty node shouldn't have right branch
- max end is not as expected!!!
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/e15a8987dabd87b1.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/util/IntervalTree.java:411
if (node.parent != null) {
// Go up parent and make sure we are on correct side
TreeNode<E,T> n = node;
while (n != null && n.parent != null) {
// Check we are either right or left
if (n == n.parent.left) {
// Check that node is less than the parent
if (node.value != null) {
if (node.value.getInterval().compareTo(n.parent.value.getInterval()) > 0) {
throw new IllegalStateException("node is not on the correct side!!!");
}
}
} else if (n == n.parent.right) {
// Check that node is greater than the parent
if (node.value.getInterval().compareTo(n.parent.value.getInterval()) <= 0) {
throw new IllegalStateException("node is not on the correct side!!!");
}
} else {
throw new IllegalStateException("node is not parent's left or right child!!!");
}
n = n.parent;
}
}
if (node.left != null) todo.add(node.left);
if (node.right != null) todo.add(node.right);
}
}
public boolean isAlphaBalanced(TreeNode<E,T> node, double alpha) {
int leftSize = (node.left != null)? node.left.size:0;
int rightSize = (node.right != null)? node.right.size:0;
int threshold = (int) (alpha*node.size) + 1;
return (leftSize <= threshold) && (rightSize <= threshold);
}
public void balance() {View on GitHub (pinned to 1b7edd19c4)