Refactor step 1 of build_tree into compute_child_tag_masks