Helper to cache permission set tree on user instance

def ensure_permission_set_tree_cached(user):
    """ Helper to cache permission set tree on user instance """
    if hasattr(user, CACHED_PSET_PROPERTY_KEY):
        return
    try:
        setattr(
            user, CACHED_PSET_PROPERTY_KEY, _get_permission_set_tree(user))
    except ObjectDoesNotExist:  # No permission set
        pass