Would you be able to do something like this instead?

```ruby
def deep_compact
  result = self.dup.deep_compact!
  result.nil? ? self : result
end
```