code: public static Map<String,Object> toObject(Collection<Attribute> attributeCollection) {
  
          requireNonNull(attributeCollection);
  
          List<Attribute> attributes = new ArrayList<>(attributeCollection);
  
          sort(attributes, new FlattenedLevelsComparator());
  
          ObjectJsonNode root = new ObjectJsonNode();
          for(Attribute attribute : attributes) {
              List<String> keys = SPLITTER.splitToList(attribute.getKey());
  
              Map<Integer, Integer> levelsIndices = levelsToIndices(attribute.getMetadata());
              String[] adjustedKeys = new String[keys.size() + levelsIndices.size()];
  
              int count = 0;
              for(int i = 0; i < adjustedKeys.length; i++) {
  
                  if(levelsIndices.containsKey(i))
                      adjustedKeys[i] = "[]";
                  else {
                      adjustedKeys[i] = keys.get(count);
                      count++;
                  }
              }
  
              root.visit(adjustedKeys, 0, levelsIndices, new ValueJsonNode(attribute.getValue()));
          }
  
          return root.toObject();
      }
docs: Re-expands a nested attribute representation from a collection of attributes back into a nested
  java object representation (objects become Map<String,Object>, arrays become Lists, and non-containers stay
  the same).
  
  NOTE: It is possible that this method could fail in the case where attributes were added to a attribute collection
  which changed from a primitive type to a container type, from one container type to another, or vice versa.