Highlight list of nodes

I have a list of nodes that i get from the node itself. (what nodes it is related to). I can highlight one of the nodes but i can not find a way to highlight all of the nodes.

    var outResults = myDiagram.findNodesByExample({
                key: array[0]
            });
myDiagram.highlightCollection(outResults);

i want to loop over “array” and get all keys and highlight all of the nodes and not only the one on position 0 as i have now hard coded.

myDiagram.commit(function(diag) {
    diag.clearHighlighteds();
    array.forEach(function(key) {
        var node = diag.findNodeForKey(key);
        if (node) node.isHighlighted = true;
      });
  }, "highlighted nodes");