public void addMergeNodesForMap(LWMap map, WeightAggregate weightAggregate, List<Style> styles) {

    Iterator<LWComponent> children =
        map.getAllDescendents(LWComponent.ChildKind.PROPER).iterator(); // map.getNodeIterator();
    while (children.hasNext()) {
      LWComponent component = children.next();
      if (component instanceof LWPortal) continue;

      if (component instanceof LWNode || component instanceof LWImage) {
        boolean repeat = false;
        if (nodeAlreadyPresent(component)) {
          repeat = true;
        }
        LWComponent node = component.duplicate();
        edu.tufts.vue.metadata.VueMetadataElement vme =
            new edu.tufts.vue.metadata.VueMetadataElement();
        vme.setType(edu.tufts.vue.metadata.VueMetadataElement.OTHER);
        String sourceLabel = node.getLabel();
        if (sourceLabel == null) sourceLabel = "";
        String sourceMap = component.getMap().getLabel();

        if (sourceMap == null) sourceMap = "";

        vme.setObject("source: " + sourceMap + "," + sourceLabel);
        node.getMetadataList().getMetadata().add(vme);
        if (!repeat) {
          if (!excludeNodesFromBaseMap || !nodePresentOnBaseMap(node)) {
            add(node);
          }
        }
      }
    }
  }
  public boolean nodeAlreadyPresent(LWComponent node) {

    if (DEBUG_LOCAL) {
      System.out.println("nodeAlreadyPresent -- getParent() " + node.getParent());
    }

    // also need to check if parent *will* be visible
    // if(! (node.getParent() instanceof LWMap ) )
    if (!node.atTopLevel()) return true;
    if (node == null) {
      return false;
    }
    // if(node.getParent() instanceof LWNode && (LWNode.isImageNode((LWNode)(node.getParent()))) )
    //     return true;
    //        Iterator<LWComponent> i = this.getAllDescendents(ChildKind.PROPER).iterator();
    //        Iterator<LWComponent> i = this. getChildList().iterator();
    for (LWComponent c : getAllDescendents(ChildKind.PROPER)) {
      if (Util.getMergeProperty(node) != null && Util.getMergeProperty(c) != null) {
        if (Util.getMergeProperty(node).equals(Util.getMergeProperty(c))) {
          if (DEBUG_LOCAL) {
            System.out.println(
                "LWMergeMap - returning true in nodeAlreadyPresent - for (node,c) ("
                    + Util.getMergeProperty(node)
                    + ","
                    + Util.getMergeProperty(c)
                    + ")");
          }
          // TODO: not sure why this code is here and what it is doing. should be refactored.
          String sourceLabel = node.getLabel();
          if (sourceLabel == null) sourceLabel = "";
          edu.tufts.vue.metadata.VueMetadataElement vme =
              new edu.tufts.vue.metadata.VueMetadataElement();
          vme.setType(edu.tufts.vue.metadata.VueMetadataElement.OTHER);
          vme.setObject("source: " + node.getMap().getLabel() + "," + sourceLabel);
          c.getMetadataList().getMetadata().add(vme);

          return true;
        }
      }
    }
    return false;
  }
  public void addMergeNodesFromSourceMap(
      LWMap map, VoteAggregate voteAggregate, HashMap<String, LWNode> nodes) {
    Iterator<LWComponent> children =
        map.getAllDescendents(LWComponent.ChildKind.PROPER).iterator(); // map.getNodeIterator();
    while (children.hasNext()) {
      // LWNode comp = (LWNode)children.next();
      LWComponent comp = children.next();

      if (comp instanceof LWPortal) continue;

      boolean repeat = false;
      if (nodeAlreadyPresent(comp)) {
        repeat = true;
        /*if(RECORD_SOURCE_NODES)
        {
          LWNode node = nodes.get(Util.getMergeProperty(comp));
          if(node.getNotes() !=null)
          {
            node.setNotes(node.getNotes()+"\n" + map.getLabel());
          }
          else
          {
            node.setNotes(map.getLabel());
          }
        }*/
      }

      if (voteAggregate.isNodeVoteAboveThreshold(Util.getMergeProperty(comp))) {
        // LWNode node = (LWNode)comp.duplicate();
        LWComponent node = comp.duplicate();

        String sourceLabel = node.getLabel();

        if (sourceLabel == null) sourceLabel = "";

        edu.tufts.vue.metadata.VueMetadataElement vme =
            new edu.tufts.vue.metadata.VueMetadataElement();
        vme.setType(edu.tufts.vue.metadata.VueMetadataElement.OTHER);

        // todo: looks like this may be needed in future -- may be an issue
        // of map list in merge maps panel -- or otherwise might require
        // more generic approach (certainly a seperate method either here or in
        // merge maps panel or in VueMetadataElement is in order)
        /*String mapLabel = comp.getMap().getLabel();

        if(mapLabel != null)
        {
            if(mapLabel.contains(".vue"))
            {
                mapLabel = mapLabel.substring(0,mapLabel.indexOf(".vue"));
            }
        }
        else
        {
            mapLabel = "";
        }*/

        vme.setObject("source: " + comp.getMap().getLabel() + "," + sourceLabel);
        node.getMetadataList().getMetadata().add(vme);

        if (!repeat) {
          /*if(RECORD_SOURCE_NODES)
          {
            if(node.getNotes() !=null)
            {
              node.setNotes(node.getNotes()+"\n" + map.getLabel());
            }
            else
            {
              node.setNotes(map.getLabel());
            }
            nodes.put(Util.getMergeProperty(comp),node);
          }*/
          // addNode(node);
          if (!excludeNodesFromBaseMap || !nodePresentOnBaseMap(node)) {
            add(node);
          }
        }
      }
    }
  }