This is really hacky, I'd suggest doing either:

1. rename this to find_optional_nested_object (remove render_error), add a second filter called find_nested_object that calls find_optional_nested_object and if it returns nil, call render_error.  Then use find_nested_object in lookup_keys/parameters etc, and use find_optional_nested_object in puppetclasses and taxonomies.
2. add an argument to control the behaviour and then change filters to use a block to call the filter with the appropriate argument