Select objects by key/value

To get better formatting of your script on this forum, please read this: