private void validateLinked(Node node) {
   if (node.getNext() == null && node.getParent() == null) {
     throw new IllegalStateException("Added block " + node + " is not linked into the AST");
   }
 }
 private void validateUnlinked(Node node) {
   if (!(node.getNext() == null && node.getParent() == null)) {
     throw new IllegalStateException("Removed block " + node + " is still linked in the AST");
   }
 }