code: def _get_permission_set_tree(user):
      
      if hasattr(user, CACHED_PSET_PROPERTY_KEY):
          return getattr(user, CACHED_PSET_PROPERTY_KEY)
      if user.is_authenticated():
          try:
              return user.permissionset.first().tree()
          except AttributeError:
              raise ObjectDoesNotExist
      return PermissionSet.objects.get(anonymous_user=True).tree()
docs: Helper to return cached permission set tree from user instance if set, else
      generates and returns analyzed permission set tree. Does not cache set
      automatically, that must be done explicitely.