<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _get_permission_set_tree(user):
 """ 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. """

    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()