By checking addresses, it would appear that:

if (mainBox.getChildren().first().data() is label.getLabelStruct()) {

does the right thing. But I am worried I am missing something about what is actually being tested here.