CLN: avoid accessing private functions
xref #33394 

@simonjayhawkins thoughts on how to handle the mypy complaint?
Yea the recursive call obviously makes things difficult. I think this is a use case for overload, where the type of input dictates the return type updated to fix the mypy concern