{% macro render_folder(folder) %}
    {% set node_player_children = foldered_node_players[folder.id]|default([]) %}
    {% set has_children = folder.children or node_player_children %}

    <li class="icon-folder li-explr-folder li-explr-folder-{{ folder.id }}">
        <a href="{% if use_href %}{{ url_for('fleet_node_player_cd') }}?path={{ folder.path }}{% else %}javascript:void(0);{% endif %}"
           class="{% if folder.path == working_folder_path %}active{% endif %} {{ 'explr-pick-folder' if not use_href }}">
            {{ folder.name }}
        </a>

        {% if has_children %}
            <ul>
                {% for child in folder.children %}
                    {{ render_folder(child) }}
                {% endfor %}
                {% for node_player in node_player_children %}
                    {% set icon = enum_operating_system.get_fa_icon(node_player.operating_system) %}
                    {% set color = enum_operating_system.get_color_icon(node_player.operating_system) %}
                    <li class="explr-item" data-entity-json="{{ json_dumps(node_player.to_dict()) }}">
                        <i class="fa {{ icon }} {{ color }} main"></i>
                        {% if node_player.group_id %}
                            <sub>
                                <i class="fa fa-layer-group"></i>
                            </sub>
                        {% endif %}
                        <a href="javascript:void(0);"
                           class="explr-pick-element"
                           {% if use_href %}data-callback="explrNodePlayerEdit"{% endif %}>
                            {{ node_player.name }}
                        </a>
                    </li>
                {% endfor %}
            </ul>
        {% endif %}
    </li>
{% endmacro %}

<ul class="explr hidden" id="tree" data-working-folder-id="{{ working_folder.id }}">
    {{ render_folder(folders_tree) }}
</ul>
