@SuppressWarnings("unchecked") private void merge(Map.Entry<Path, Object> simpleEntry, Map<String, Object> compositionMap) { Path path = simpleEntry.getKey(); String head = path.head(); assert head != null; Object nextLevelComposition = compositionMap.get(head); Path tail = path.tail(); Object simpleValue = simpleEntry.getValue(); if (nextLevelComposition == null) { mergeEntryIntoEmptySlot(compositionMap, head, tail, simpleValue); } else if (Types.isSimple(nextLevelComposition)) { mergeEntryWithSimple(compositionMap, nextLevelComposition, head, tail, simpleValue); } else { mergeEntryWithStructure((Map<String, Object>) nextLevelComposition, tail, simpleValue); } }