package org.jetbrains.dokka import com.intellij.psi.* import kotlin.support.* fun PsiElement.children(): Stream { val parent = this var current: PsiElement? = null return object : Stream { override fun iterator(): Iterator = object : AbstractIterator() { { setNext(parent.getFirstChild()) } override fun computeNext() { current = current?.getNextSibling() if (current == null) done() else setNext(current!!) } } } }