inner variable is never gonna be null, because getChildren returns empty list in case there is no children with given name. It would work even without any checks before calling unmarshallPackageList.