Get root widget of UMG in blueprints?

For anyone in need of the “Get Root Widget” function in blueprints, especially in the dynamic widget tree where assigning manually isn’t practical, here’s a recursive function inspired by “BDC_Patrick :de::uk::us:” from the Discord community.
I have tested it. Started from Image. Got the CanvasPanel. Not the Top “CustomUserWidget” as I expected. But this might be handy for you.

In case of the image not loaded properly:

UUserWidget* FindRootWidget(UUserWidget* CurrentWidget)
{
    if(!IsValid(CurrentWidget->GetParent())){
        return CurrentWidget;
    }
    return FindRootWidget(CurrentWidget->GetParent());
}