def cut(self, d):
        Parameter.checkInt(d, 0, float("inf"))

        root = self.getRootId()
        newTree = DictTree()
        stack = [(root, 0)]

        newTree.setVertex(root)

        while(len(stack) != 0):
            (vertexId, depth) = stack.pop()
            neighbours = self.neighbours(vertexId)

            if depth <= d:
                newTree.setVertex(vertexId, self.getVertex(vertexId))

            for neighbour in neighbours:
                stack.append((neighbour, depth+1))

                if depth+1 <= d:
                    newTree.addEdge(vertexId, neighbour, self.getEdge(vertexId, neighbour))

        return newTree
Return a new tree containing all the vertices of the current one up to
dataset/ETHPy150Open charanpald/APGL/apgl/graph/DictTree.py/DictTree.cut