### Question:
HashTree { public static Builder builder() { return new Builder(); } private  HashTree(
      final Bytes32 rootHash,
      final Map<Bytes32, Bytes32> childToParent,
      final Map<Bytes32, Set<Bytes32>> parentToChildren); static Builder builder(); Builder updater(); Builder withRoot(final Bytes32 newRootHash); Bytes32 getRootHash(); Optional<Bytes32> getParent(final Bytes32 childRoot); Set<Bytes32> getAllRoots(); void processHashesInChain(final Bytes32 head, NodeProcessor processor); List<Bytes32> collectChainRoots(
      final Bytes32 head, Function<Bytes32, Boolean> shouldContinue); void processHashesInChainWhile(final Bytes32 head, HaltableNodeProcessor nodeProcessor); int countChildren(final Bytes32 hash); boolean contains(final Bytes32 blockRoot); int size(); Stream<Bytes32> preOrderStream(); Stream<Bytes32> breadthFirstStream(); @Override boolean equals(Object o); @Override int hashCode();  }### Answer:
@Test public void build_singleChain() { final SignedBeaconBlock baseBlock = dataStructureUtil.randomSignedBeaconBlock(0); final List<SignedBeaconBlock> descendants = dataStructureUtil.randomSignedBeaconBlockSequence(baseBlock, 5); final List<SignedBeaconBlock> chain = new ArrayList<>(); chain.add(baseBlock); chain.addAll(descendants); final HashTree blockTree = HashTree.builder().rootHash(baseBlock.getRoot()).block(baseBlock).blocks(chain).build(); validateTreeRepresentsChain(blockTree, chain); }
@Test public void build_ignoreRandomBlock() { final SignedBeaconBlock baseBlock = dataStructureUtil.randomSignedBeaconBlock(0); final List<SignedBeaconBlock> descendants = dataStructureUtil.randomSignedBeaconBlockSequence(baseBlock, 5); final SignedBeaconBlock randomBlock = dataStructureUtil.randomSignedBeaconBlock(2); final List<SignedBeaconBlock> chain = new ArrayList<>(); chain.add(baseBlock); chain.addAll(descendants); final HashTree blockTree = HashTree.builder().rootHash(baseBlock.getRoot()).blocks(chain).block(randomBlock).build(); validateTreeRepresentsChain(blockTree, chain); }
@Test public void build_withInvalidFork() { final SignedBeaconBlock genesis = dataStructureUtil.randomSignedBeaconBlock(0); final List<SignedBeaconBlock> chain = dataStructureUtil.randomSignedBeaconBlockSequence(genesis, 8); final SignedBeaconBlock baseBlock = chain.get(0); final List<SignedBeaconBlock> invalidFork = dataStructureUtil.randomSignedBeaconBlockSequence(genesis, 3); final HashTree blockTree = HashTree.builder().rootHash(baseBlock.getRoot()).blocks(chain).blocks(invalidFork).build(); validateTreeRepresentsChain(blockTree, chain); }