code: def get_obj(self, vimtype, name, return_all=False, path=""):
          
          obj = list()
          if path:
              obj_folder = self.content.searchIndex.FindByInventoryPath(path)
              container = self.content.viewManager.CreateContainerView(
                  obj_folder, vimtype, True
              )
          else:
              container = self.content.viewManager.CreateContainerView(
                  self.content.rootFolder, vimtype, True)
  
          for c in container.view:
              if name in [c.name, c._GetMoId()]:
                  if return_all is False:
                      return c
                      break
                  else:
                      obj.append(c)
  
          if len(obj) > 0:
              return obj
          else:
              # for backwards-compat
              return None
docs: Get the vsphere object associated with a given text name or MOID