If you just want to limit the scope of your intermediate variable, you can also just create a block around the predicate:
val n = getNodeByMagic()
val passesTest = {
val child = n.child
child.length == 0 && !child.filter(_.isInstanceOf[Text]).isEmpty
}
// child is not defined outside of the block