Jsfl delete element from library item timeline

Hi,
I’m somewhat new to JSFL. I’m currently writing a batch process that will cycle through every frame of every item in the library with a linkage, and deletes instances of any other library items with a linkage.
The only way I could find to delete an element is by making it the document selection and deleting the selection.
Unfortunately, I can’t get it to select the element. I’ve done a trace, so I know I have the right element stored, but when I run:

var doc = fl.getDocumentDOM();

...

for (var l = layer.frames[j].elements.length - 1; l >= 0; l--)
{
    element = layer.frames[j].elements[l];
    if (element.elementType == "instance")
        if (element.libraryItem.linkageExportForAS)
        {
            doc.selectNone();
            doc.selection = [element];
            fl.outputPanel.trace(doc.selection.length + " " + element);
            doc.deleteSelection();
            doc.selectNone();
        }
}

no selection is made, and the trace reads: 0 [object SymbolInstance]

I also tried fl.selectElement, but I get “fl.selectElement is not a function”

Can anyone see what I’m doing wrong here?