def _mark_selected(path, byurl):
    """process the tree (flattened and sorted by url) to mark the entries
    selected which appear on the path, as well as their parent entries.
    """
    clear = []
    check = path.startswith
    for url, val in byurl:
        pt = val['path_type']
        if pt == 'N':
            continue
        elif pt != 'A' and path != url:
            continue
        elif check(url):
            while val:
                if val['selected']:
                    break
                if val['path_type'] == 'N' or val['path_type'
                    ] == 'E' and path != val['url']:
                    clear.append(val)
                val['selected'] = True
                val = val['parent']
    for ent in clear:
        ent['selected'] = False
