def _traverse_tree_and_group_all_objects_by_oclass(root_obj, result=None):
    """Traverses the tree once and groups all objects by oclass

    :param root_obj: The root object where to start the traversion
    :type root_obj: CUDS
    :param result: The current results of the recursion, defaults to None
    :type result: dict, optional
    :return: All CUDS objects in the tree, grouped by oclass.
    :rtype: dict
    """
    if result is None:
        result = {str(root_obj.oclass): [root_obj]}
    for neighbour in root_obj.iter():
        if neighbour.oclass not in result.keys():
            result[str(neighbour.oclass)] = [neighbour]
        else:
            result[str(neighbour.oclass)].append(neighbour)
        _traverse_tree_and_group_all_objects_by_oclass(neighbour, result)
    return result