code: def _strip_object(key):
      
      if hasattr(key, 'version_agnostic') and hasattr(key, 'for_branch'):
          return key.for_branch(None).version_agnostic()
      else:
          return key
docs: Strips branch and version info if the given key supports those attributes.