The goal is to avoid generating $set update operations if no field in control.min or control.max is changes, and otherwise to directly generate the $set if the fields that need changes, at a level that could directly become part of an oplog entry, without using aggregation expressions.
One idea is to have something like a data structure recursively defined that contains an unordered map, a vector, and a BSONObj. If the min/max is an object, the map will be populated. If it's an array, the vector will be populated. If it's a leaf, the BSONObj is populated. Then, when BucketCatalog::commit is called, we can either construct the complete min/max object in the insert case, or the $set fields in the update case. This way, as more inserts occur, we can iterate through the document being inserted and update the current min/max without having to reconstruct the BSONObj every time.