Add a generic function for filtering API objects

Replace the filter_nodes() function with a more generic solution.
We can now filter a list of generic API object, by any attribute.

Change-Id: I76f8226df5123a8038220658cb340b67461024b4