Filter out empty children before building the tree.