add {key: test} pattern

This allows you to match a path to the keys of an object.
On example of where this is useful is in a dependencies field of a package.json.
`test` can be boolean or function or a regular expression, and is treated as a normal test,
except that the key will be returned instead of the value. `{key: test}` only makes sense as the
last item in the path, so it terminates searching when a key match is found.

This pull request also adds a test and simplifies `isRegExp` to use duck typing.