code: public Metadata createMetadata() {
      Metadata metadata = new Metadata();
      for (TagValue tag : getMetadata().getTags()) {
        if (tag.getCardinality() == 1) {
          abstractTiffType t = tag.getValue().get(0);
          if (t.isIFD()) {
            Metadata metadata2 = ((IFD) t).createMetadata();
            for (String key : metadata2.keySet()) {
              metadata.add(key, metadata2.get(key));
            }
          } else if (t.containsMetadata()) {
            try {
              Metadata meta = t.createMetadata();
              metadata.addMetadata(meta);
            } catch (Exception ex) {
              // TODO: What?
            }
          }
        }
      }
      return metadata;
    }
docs: Create IFD metadata.