'Fetch folders from a Wrike account and add them to the
data tree
@param root: the root element of the data tree
@param account_id: the Wrike account ID'

def fetch_folders(self, root, account_id):

    (response, message) = self._send_request(path=('accounts/%s/folders' % account_id))
    if (not response):
        return (None, message)
    folders = {}
    data = response.get('data')
    if (data and (type(data) is list)):
        SubElement = etree.SubElement
        for folder_data in data:
            scope = folder_data.get('scope')
            if (scope not in ('WsFolder', 'RbFolder')):
                continue
            folder_id = folder_data.get('id')
            folder = SubElement(root, 'folder', id=str(folder_id))
            folders[folder_id] = folder
            if (scope == 'RbFolder'):
                folder.set('deleted', str(True))
            else:
                title = SubElement(folder, 'title')
                title.text = folder_data.get('title')
                account = SubElement(folder, 'accountId')
                account.text = str(account_id)
    return (folders, None)
