code: def get_template(template, relation):
      
      if isinstance(relation, Entry):
          path = relation.category.path
      elif isinstance(relation, Category):
          path = relation.path
      else:
          path = relation
  
      tmpl = map_template(path, template)
      return tmpl.filename if tmpl else None
docs: Given an entry or a category, return the path to a related template