I'm able to get Java/Groovy variables within a given scope using PsiScopesUtil.treeWalkUp(). I'm also able to get Python variables within a given scope using ControlFlowCache.getScope().getNamedElements().
What are the equivalent methods for doing this in Kotlin? I get no results when I use PsiScopesUtil.treeWalkUp() inside a Kotlin function. Are there more universal ways of doing this? PsiElement.processDeclarations() looks promising, but I can't get it to return anything either.