code: def get_primitive_type(stmt):
      
      type_obj = stmt.search_one('type')
      type_name = getattr(type_obj, 'arg', None)
      typedef_obj = getattr(type_obj, 'i_typedef', None)
      if typedef_obj:
          type_name = get_primitive_type(typedef_obj)
      elif type_obj and not check_primitive_type(type_obj):
          raise Exception('%s is not a primitive! Incomplete parse tree?' %
                          type_name)
      return type_name
docs: Recurses through the typedefs and returns
      the most primitive YANG type defined.