void (CharSequence node) { if (node instanceof ImmutableText.CompositeNode) { CharSequence head = ((ImmutableText.CompositeNode)node).head; CharSequence tail = ((ImmutableText.CompositeNode)node).tail; int headLength = head.length(); int tailLength = tail.length(); assertTrue("unbalanced: head " + headLength + ", tail " + tailLength, headLength <= tailLength * 2 && tailLength <= headLength * 2); assertBalanced(head); assertBalanced(tail); } }