It would be nice to add comments to these lines (and to 622-627) explaining the logic. Here, you're taking the union of the bounds, below you're taking the intersection of the bounds.