def find_object(self, pattern):
        obj = None
        error = None
        pattern = pattern.strip()
        if pattern == '*':
            obj = [h.host_name for h in list(self.all_elements.items.values())
                   if getattr(h, 'host_name', '') != '' and not h.is_tpl()]
            return obj, error
        if self.ctx == 'hostgroups':
            hgr = self.grps.find_by_name(pattern)
            if not hgr:
                error = "Error : cannot find the %s of the expression '%s'" % (self.ctx, pattern)
                return hgr, error
            elts = hgr.get_hosts()
            elts = strip_and_uniq(elts)
            if '*' in elts:
                elts.extend([h.host_name for h in list(self.all_elements.items.values())
                             if getattr(h, 'host_name', '') != '' and not h.is_tpl()])
                elts.remove('*')
            return elts, error
        obj = self.grps.find_hosts_that_use_template(pattern)
        return obj, error