boolean (FacetEditorFacade editor, final FacetType<?, ?> type) { final ModuleType moduleType = editor.getSelectedModuleType(); if (moduleType == null || !type.isSuitableModuleType(moduleType)) { return false; } final FacetTypeId<?> underlyingTypeId = type.getUnderlyingFacetType(); final FacetInfo selectedFacet = editor.getSelectedFacetInfo(); if (selectedFacet == null) { return underlyingTypeId == null && canAddFacet(null, type, editor); } final FacetTypeId selectedFacetType = selectedFacet.getFacetType().getId(); if (selectedFacetType == underlyingTypeId) { return canAddFacet(selectedFacet, type, editor); } final FacetInfo parent = editor.getParent(selectedFacet); if (!canAddFacet(parent, type, editor)) { return false; } return parent == null && underlyingTypeId == null || parent != null && parent.getFacetType().getId() == underlyingTypeId; }