### Question:
Node { static Node mergeLeaves(Node rope1, Node rope2) { if (!rope1.isLeaf() || !rope2.isLeaf()) { throw new IllegalArgumentException("mergeLeaves() called with non-leaf node"); } if (rope1.getLength() >= MIN_LEAF && rope2.getLength() >= MIN_LEAF) { return Node.fromPieces(Arrays.asList(rope1, rope2)); } String rope1String = rope1.getLeaf(); String rope2String = rope2.getLeaf(); String ropeString = rope1String + rope2String; if (ropeString.length() <= MAX_LEAF) { return Node.fromStringPiece(ropeString); } else { int splitPoint = findLeafSplitForMerge(ropeString); String leftString = ropeString.substring(0, splitPoint); String rightString = ropeString.substring(splitPoint); Node leftNode = Node.fromStringPiece(leftString); Node rightNode = Node.fromStringPiece(rightString); return Node.fromPieces(Arrays.asList(leftNode, rightNode)); } } Node(NodeBody nodeBody); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString();  }### Answer:
@Test public void testMergeLeaves() { Node hello = Node.fromString("hello"); Node world = Node.fromString("world"); Node mergedLeaves = Node.mergeLeaves(hello, world); Node helloWorld = Node.fromString("helloworld"); assertEquals(mergedLeaves, helloWorld); assertNotEquals(mergedLeaves, hello); assertNotEquals(mergedLeaves, world); mergedLeaves = hello.mergeLeaf(world); assertEquals(helloWorld, mergedLeaves); assertEquals(hello, Node.fromString("hello")); assertEquals(world, Node.fromString("world")); }