# Path: src/pubsub/core/topicobj.py
# class Topic:
#     pass


from enum import IntEnum
from .topicobj import Topic
    def __init__(self, visitor: ITopicTreeVisitor = None):
        """The visitor, if given, must adhere to API of ITopicTreeVisitor."""
        self.__handler = visitor

    def setVisitor(self, visitor: ITopicTreeVisitor):
        """The visitor must adhere to API of ITopicTreeVisitor."""
        self.__handler = visitor

    def traverse(self, topicObj: Topic, how: TreeTraversal = TreeTraversal.DEPTH, onlyFiltered: bool = True):
        """
        Start traversing tree at topicObj. Note that topicObj is a
        Topic object, not a topic name. The how defines if tree should
        be traversed breadth or depth first. If onlyFiltered is
        False, then all nodes are accepted (_accept(node) not called).

        This method can be called multiple times.
        """
        if how == TreeTraversal.MAP:
            raise NotImplementedError('not yet available')

        self.__handler._startTraversal()

        if how == TreeTraversal.BREADTH:
            self.__traverseBreadth(topicObj, onlyFiltered)
        else:
            assert how == TreeTraversal.DEPTH
            self.__traverseDepth(topicObj, onlyFiltered)

        self.__handler._doneTraversal()


# Path: src/pubsub/core/topicobj.py
# class Topic:
#     pass


# Path: src/pubsub/core/topictreetraverser.py
from enum import IntEnum
from .topicobj import Topic

    def __init__(self, visitor: ITopicTreeVisitor = None):
        """The visitor, if given, must adhere to API of ITopicTreeVisitor."""
        self.__handler = visitor

    def setVisitor(self, visitor: ITopicTreeVisitor):
        """The visitor must adhere to API of ITopicTreeVisitor."""
        self.__handler = visitor

    def traverse(self, topicObj: Topic, how: TreeTraversal = TreeTraversal.DEPTH, onlyFiltered: bool = True):
        """
        Start traversing tree at topicObj. Note that topicObj is a
        Topic object, not a topic name. The how defines if tree should
        be traversed breadth or depth first. If onlyFiltered is
        False, then all nodes are accepted (_accept(node) not called).

        This method can be called multiple times.
        """
        if how == TreeTraversal.MAP:
            raise NotImplementedError('not yet available')

        self.__handler._startTraversal()

        if how == TreeTraversal.BREADTH:
            self.__traverseBreadth(topicObj, onlyFiltered)
        else:
            assert how == TreeTraversal.DEPTH
            self.__traverseDepth(topicObj, onlyFiltered)

        self.__handler._doneTraversal()


    def __traverseBreadth(self, topicObj: Topic, onlyFiltered: bool):