Iterable<String> (@NotNull String className, @NotNull GenerationNode node, @NotNull String elementSeparator, @NotNull String modifierSeparator) { className = fillWithBemElements(className, node, elementSeparator); className = fillWithBemModifiers(className, node, modifierSeparator); BemState nodeBemState = BEM_STATE.get(node); BemState bemState = extractBemStateFromClassName(className, elementSeparator, modifierSeparator); List<String> result = new ArrayList<>(); if (!bemState.isEmpty()) { String nodeBlockValue = nodeBemState != null ? nodeBemState.getBlock() : null; String block = bemState.getBlock(); if (StringUtil.isEmpty(block)) { block = StringUtil.notNullize(nodeBlockValue); bemState.setBlock(block); } String prefix = block; String element = bemState.getElement(); if (StringUtil.isNotEmpty(element)) { prefix += elementSeparator + element; } result.add(prefix); String modifier = bemState.getModifier(); if (StringUtil.isNotEmpty(modifier)) { result.add(prefix + modifierSeparator + modifier); } BemState newNodeBemState = bemState.copy(); if (StringUtil.isNotEmpty(nodeBlockValue) && StringUtil.isEmpty(modifier)) { // save old value newNodeBemState.setBlock(nodeBlockValue); } BEM_STATE.set(node, newNodeBemState); } else { result.add(className); } return result; }