if (!resourceDesc.isDefined()) {

^^^ is how you check for an undefined node.