fun <T, ID> CrudRepository<T, ID>.visit(start: ID?, visitor: (T) -> Boolean) where T: TreeNode<ID> {
var currentId = start
do {
val node = findByIdOrNull(currentId!!)
if (node != null) {
if (!visitor(node)) {
break
}
}
currentId = node?.getParentId()
} while (node != null && !node.isRoot())
}
标签:node,递归,visitor,start,currentId,对树,null,访问者
From: https://www.cnblogs.com/Acaak/p/17009450.html