Right, we don't need to writeTree here.
Actually, removing this method call revealed a bug in the addIfNotNull method below which caused the NoteMapMergerTest.testCollapseFanoutAfterMerge to fail with a "Missing tree ...". When the child parameter in the addIfNotNull is an instance of InMemoryNoteBucket then we should have added it to the fanout bucket using the other setBucket method:

 void setBucket(int cell, InMemoryNoteBucket bucket)

Adding it using the child.getTreeId() causes the estimateSize method to fail because it finds a LazyNoteBucket in a cell for which the tree object doesn't exist in the Git object database.