Is there a more idiomatic way to filter objects by value?