Actually, as a further improvement, I would just take `MaxHeap` take a `maxSize` parameter for how many elements to keep, and have it implement this logic in `insert`. That way callers don't have to decide whether to call `insert` or `replaceRoot`. Just make the API for it as simple as possible.