Initialize custom Widget without using Annotation

I’m trying to initialize a custom widget without using Annotation (OverrideWidget), the reason behind this is that I have a complicated logic in finding the parent element that gets passed to the custom widget and using @FindBy annotation would not be enough for my case.

I tried initializing the custom widget using PageFactory#initElements but yield no success.

Thanks for the help in advance.