RefPackage (RefEntity refEntity) { while (refEntity != null && !(refEntity instanceof RefPackage)) { if (refEntity instanceof RefElement) { ((RefElement)refEntity).initializeIfNeeded(); } refEntity = refEntity.getOwner(); } return (RefPackage)refEntity; }