This function is recursive, if it finds another table, it calls for itself, also it can handle "self reference" cases (_G = _G._G) and so on.
And I can modify this function a little bit and call it inside the scope that the possible local table is.
But thanks anyways,