code: def _get_next_resource(self, resource, next_resource_name, selectors):
          
          # don't fetch twice
          if 'id_perms' not in resource:
              resource.fetch()
  
          res = None
          for res_list in (getattr(resource.refs, next_resource_name),
                           getattr(resource.back_refs, next_resource_name),
                           getattr(resource.children, next_resource_name)):
              res = self._select_next_resource(res_list, selectors)
              if res is not None:
                  break
  
          if res is None:
              raise CommandError("Resource '%s' is not linked to resource type '%s'" %
                                 (self.current_path(resource), next_resource_name))
  
          return (res.type, res)
docs: :param resource: Resource (not necessary fetched)
          :param next_resource_name: string
          :rtype: (resource_type, resource_path)