Comparing the occupancys and merging the trees