I personally use something like this (vertical tree traversal using recursion)
fun ViewGroup.deepForEach(function: View.() -> Unit) {
this.forEach { child ->
child.function()
if (child is ViewGroup) {
child.deepForEach(function)
}
}
}
usage :
viewGroup.deepForEach { isEnabled = false }