public static List<MultivaluedHierarchicalFacet> createMultivaluedHierarchicalFacets(
      String fieldName, List<String> facetValues) {
    Map<String, MultivaluedHierarchicalFacet> facetMap =
        new LinkedHashMap<String, MultivaluedHierarchicalFacet>();
    for (String facetValue : facetValues) {
      try {
        MultivaluedHierarchicalFacetNode node = new MultivaluedHierarchicalFacetNode(facetValue);
        String firstTier = node.getTiers().get(0);

        MultivaluedHierarchicalFacet matchingFacet = facetMap.get(firstTier);
        if (matchingFacet == null) {
          matchingFacet = new MultivaluedHierarchicalFacet(fieldName);
          facetMap.put(firstTier, matchingFacet);
        }
        matchingFacet.addNode(node);
      } catch (InvalidHierarchicalFacetException e) {
        log.warn("Invalid hierarchical facet", e);
      }
    }
    for (MultivaluedHierarchicalFacet facet : facetMap.values()) {
      facet.sortTiers();
    }

    return new ArrayList<MultivaluedHierarchicalFacet>(facetMap.values());
  }
  public MultivaluedHierarchicalFacet(MultivaluedHierarchicalFacet facet) {
    super(facet);
    this.displayValue = facet.getDisplayValue();

    for (HierarchicalFacetNode node : facet.getFacetNodes()) {
      MultivaluedHierarchicalFacetNode newNode =
          new MultivaluedHierarchicalFacetNode(node.getFacetValue());
      this.facetNodes.add(newNode);
    }
  }
 public void setDisplayValues(MultivaluedHierarchicalFacet facet) {
   int startingCount = this.facetNodes.size();
   String targetJoined = this.getLastNode().joinTiers(false);
   for (HierarchicalFacetNode node : facet.getFacetNodes()) {
     MultivaluedHierarchicalFacetNode targetNode =
         (MultivaluedHierarchicalFacetNode) this.getNodeBySearchValue(node.getSearchValue());
     if (targetNode != null) {
       log.debug("Adding in display value " + node.getDisplayValue());
       targetNode.setDisplayValue(node.getDisplayValue());
     } else {
       String joined = ((MultivaluedHierarchicalFacetNode) node).joinTiers(false);
       if (targetJoined.indexOf(joined) == 0) {
         log.debug(
             "Adding in missing node " + node.getSearchValue() + "," + node.getDisplayValue());
         this.facetNodes.add((HierarchicalFacetNode) node.clone());
       }
     }
   }
   // If the number of nodes has changed, then resort
   if (this.facetNodes.size() != startingCount) {
     this.sortTiers();
   }
 }