Multiple Select2 InitSelection Values (Part 2)

http://stackoverflow.com/questions/25707054/setting-value-in-select2-using-javascript-object-as-data-source

HTML

<script src="//cdnjs.cloudflare.com/ajax/libs/select2/3.5.0/select2.min.js"></script>
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/select2/3.5.0/select2.css">
<div>
    <h3>Test Case 1 - Pre-select All</h3>
    <div id="myselect-1"></div>
</div>

<div>
    <h3>Test Case 2 - Pre-select Parents Only</h3>
    <div><input id="myselect-2" value="1,2,3,5,9" /></div>
</div>

<div>
    <h3>Test Case 3 - Pre-select Children Only</h3>
    <div id="myselect-3"></div>
</div>

<div>
    <h3>Test Case 4 - Pre-select A Parent And All Its Children</h3>
    <div><input id="myselect-4" value="5,4,6" /></div>
</div>

<div>
    <h3>Test Case 5 - No Pre-selections</h3>
    <div id="myselect-5"></div>
</div>

<div>
    <h3>Test Case 6 - Non-Existing Pre-selections</h3>
    <div id="myselect-6"></div>
</div>

<div>
    <h3>Test Case 7 - Single Pre-selection</h3>
    <div id="myselect-7"></div>
</div>

JavaScript

(function($){
    selections = [{
        "key": "1",
        "id": "1",
        "text": "Edit Suite 1",
        "parent_id": "0",
        "type": "1",
        "description": "Avid Media Composer",
        "icon": "ca686ae1_S.png",
        "level": 0
    },
    {
        "key": "2",
        "id": "2",
        "text": "Edit Suite 2",
        "parent_id": "0",
        "type": "1",
        "description": "Avid Media Composer",
        "icon": null,
        "level": 0
    },
    {
        "key": "3",
        "id": "3",
        "text": "Edit Suite 3",
        "parent_id": "0",
        "type": "1",
        "description": "Avid ProTools",
        "icon": null,
        "level": 0
    },
    {
        "key": "5",
        "id": "5",
        "text": "Cameras",
        "parent_id": "0",
        "type": "4",
        "description": "",
        "icon": null,
        "children": [
            {
                "key": "4",
                "id": "4",
                "text": "Alexa Camera",
                "parent_id": "5",
                "type": "3",
                "description": "",
                "icon": null
            },
            {
                "key": "6",
                "id": "6",
                "text": "RED Epic Camera",
                "parent_id": "5",
                "type": "3",
                "description": "",
                "icon": null
            }
        ],
        "level": 0
    },
    {
        "key": "9",
        "id": "9",
        "text": "Staff",
        "parent_id": "0",
        "type": "4",
        "description": "",
        "icon": null,
        "children": [
            {
                "key": "8",
                "id": "8",
                "text": "Tim Mohr",
                "parent_id": "9",
                "type": "2",
                "description": "",
                "icon": null
            },
            {
                "key": "7",
                "id": "7",
                "text": "Someone Else",
                "parent_id": "9",
...