FBlueprintEditorUtils::GetLevelFromBlueprint

If a blueprint is directly tied to a level (level script and anonymous blueprints), this will return a pointer to that level