Fixes #3309: Support deep merging of hash and array structures in smart class parameters

This relates to feature 3636 which states a couple of changes to the way `lookup_keys` work
I'm creating a PR to get comments of this part of the change and to see that I'm in the right direction
Could you please split this method into two and add test for each? Also I'd add some helper methods like `supports_merge?` and `supports_uniq?` instead of comparing key_type. This seems to be useful in views as well.