protected function build_node($rootpath, $path, $name, $isdir, $rootnodepath) {
        global $OUTPUT;

        $relpath = trim($path, '/') . '/' . $name;
        $abspath = $rootpath . $relpath;
        $node = array(
            'title' => $name,
            'datecreated' => filectime($abspath),
            'datemodified' => filemtime($abspath),
        );

        if ($isdir) {
            $node['children'] = array();
            $node['thumbnail'] = $OUTPUT->image_url(file_folder_icon(90))->out(false);
            $node['path'] = $this->build_node_path('browse', $relpath, $name, $rootnodepath);

        } else {
            $node['source'] = $relpath;
            $node['size'] = filesize($abspath);
            $node['thumbnail'] = $OUTPUT->image_url(file_extension_icon($name, 90))->out(false);
            $node['icon'] = $OUTPUT->image_url(file_extension_icon($name, 24))->out(false);
            $node['path'] = $relpath;

            if (file_extension_in_typegroup($name, 'image') && ($imageinfo = @getimagesize($abspath))) {
                // This means it is an image and we can return dimensions and try to generate thumbnail/icon.
                $token = $node['datemodified'] . $node['size']; // To prevent caching by browser.
                $node['realthumbnail'] = $this->get_thumbnail_url($relpath, 'thumb', $token)->out(false);
                $node['realicon'] = $this->get_thumbnail_url($relpath, 'icon', $token)->out(false);
                $node['image_width'] = $imageinfo[0];
                $node['image_height'] = $imageinfo[1];
            }
        }

        return $node;
    }