This works in many cases, however, it is incomplete since there are cases where classes are extracted to top-level and therefore reparented. Therefore, we lose the information about the function class are nested inside.
#KT-14416 Fixed #KT-26165 Fixed