Refactoring _get_obj to make it more manageable