code: private void mapAttributes(List<Attribute> input, Map<String, List<Attribute>> output) {
          Iterator<Attribute> it = input.iterator();
          while (it.hasNext()) {
              Attribute attr = it.next();
              String id = attr.getId().toString();
  
              if (output.containsKey(id)) {
                  List<Attribute> list = output.get(id);
                  list.add(attr);
              } else {
                  List list = new ArrayList<Attribute>();
                  list.add(attr);
                  output.put(id, list);
              }
          }
      }
docs: Generic routine for resource, attribute and environment attributes
  to build the lookup map for each. The Form is a Map that is indexed
  by the String form of the attribute ids, and that contains Sets at
  each entry with all attributes that have that id