function _destroyEditorIfUnneeded(document) {
        var editor = document._masterEditor;

        if (!editor) {
            return;
        }
        
        // If outgoing editor is no longer needed, dispose it
        var isCurrentDocument = (DocumentManager.getCurrentDocument() === document);
        var isInWorkingSet = (DocumentManager.findInWorkingSet(document.file.fullPath) !== -1);
        if (!isCurrentDocument && !isInWorkingSet) {
            // Destroy the editor widget (which un-refs the Document and reverts it to read-only mode)
            editor.destroy();
            
            // Our callers should really ensure this, but just for safety...
            if (_currentEditor === editor) {
                _currentEditorsDocument = null;
                _currentEditor = null;
            }
        }
    }
Disposes the given Document's full-size editor if the doc is no longer "open" from the user's
standpoint - not in the working set and not currentDocument).

Destroying the full-size editor releases ONE ref to the Document; if inline editors or other
UI elements are still referencing the Document it will still be 'open' (kept alive) from
DocumentManager's standpoint. However, destroying the full-size editor does remove the backing
"master" editor from the Document, rendering it immutable until either inline-editor edits or
currentDocument change triggers _createFullEditorForDocument() full-size editor again.

In certain edge cases, this is called directly by DocumentManager; see _gcDocuments() for details.

@param {!Document} document Document whose "master" editor we may destroy