### Question:
TreeContainsSubtree { public static boolean containsTree(BinaryTree haystack, BinaryTree needle) { if ((haystack == needle) || (needle == null)) { return true; } return subTree(haystack, needle); }  static boolean containsTree(BinaryTree haystack, BinaryTree needle);  }### Answer:
@Test public void testContainsTree1() { BinaryTree haystack = new BinaryTree(1, new BinaryTree(2, new BinaryTree(3, null, null), null), new BinaryTree(2, new BinaryTree(3, null, null), null)); BinaryTree needle = new BinaryTree(3, null, null); assertThat("Expected result: contains = true", containsTree(haystack, needle), is(true)); }
@Test public void testContainsTree2() { BinaryTree haystack = new BinaryTree(1, new BinaryTree(2, new BinaryTree(3, null, null), null), new BinaryTree(2, new BinaryTree(3, null, null), null)); BinaryTree needle = new BinaryTree(2, null, null); assertThat("Expected result: contains = false", containsTree(haystack, needle), is(false)); }
@Test public void testContainsTree3() { BinaryTree haystack = new BinaryTree(1, new BinaryTree(2, new BinaryTree(3, null, null), new BinaryTree(4, null, null)), new BinaryTree(2, new BinaryTree(3, null, null), null)); BinaryTree needle = new BinaryTree(4, null, null); assertThat("Expected result: contains = true", containsTree(haystack, needle), is(true)); }
@Test public void testContainsTree4() { BinaryTree haystack = new BinaryTree(1, new BinaryTree(2, new BinaryTree(3, null, null), new BinaryTree(4, null, null)), new BinaryTree(2, new BinaryTree(3, null, null), null)); BinaryTree needle = new BinaryTree(4, null, new BinaryTree(5, null, null)); assertThat("Expected result: contains = false", containsTree(haystack, needle), is(false)); }