Performing `Hash#compact` implementation

https://gist.github.com/tinogomes/8332883