private function displayNode(
        SwatDataTreeNode $node,
        $nodes = 0,
        $parent_index = ''
    ) {
        // build a unique id of the indexes of the tree
        if ($parent_index === '' || $parent_index === null) {
            // index of the first node is just the node index
            $index = $node->getIndex();
        } else {
            // index of other nodes is a combination of parent indexes
            $index = $parent_index . '.' . $node->getIndex();

            echo '<li>';

            if (isset($node->value)) {
                $this->input_tag->id = $this->id . '_' . $index;
                $this->input_tag->value = $node->value;

                if (in_array($node->value, $this->values)) {
                    $this->input_tag->checked = 'checked';
                } else {
                    $this->input_tag->checked = null;
                }

                if (!$this->isSensitive()) {
                    $this->input_tag->disabled = 'disabled';
                }

                $this->label_tag->for = $this->id . '_' . $index;
                $this->label_tag->setContent($node->title);

                echo '<span class="swat-checkbox-wrapper">';
                $this->input_tag->display();
                echo '<span class="swat-checkbox-shim"></span>';
                echo '</span>';
                $this->label_tag->display();
            } else {
                echo SwatString::minimizeEntities($node->title);
            }
        }

        // display children
        $child_nodes = $node->getChildren();
        if (count($child_nodes) > 0) {
            echo '<ul>';
            foreach ($child_nodes as $child_node) {
                $nodes = $this->displayNode($child_node, $nodes, $index);
            }
            echo '</ul>';
        }

        if ($parent_index !== '' && $parent_index !== null) {
            echo '</li>';
        }

        // count checkable nodes
        if ($node->value !== null) {
            $nodes++;
        }

        return $nodes;
    }