nodesVisited.insert(edge);
resultNodesNEdges.insert(edge);
    public OSet visitGraph(        LatencyNode startNode,        boolean travelUpstream,        boolean travelDownstream,        StreamInterface withinStream,        boolean visitNodes,        boolean visitEdges)    {        ASSERT(startNode);        DLList nodesToExplore = new DLList();        nodesToExplore.pushBack(startNode);        OSet nodesVisited = new OSet();        nodesVisited.insert(startNode);        OSetIterator lastNodeVisited = nodesVisited.end();        OSet resultNodesNEdges = new OSet();        if (visitNodes)            resultNodesNEdges.insert(startNode);        while (!nodesToExplore.empty())        {            LatencyNode node = (LatencyNode)nodesToExplore.begin().get();            nodesToExplore.popFront();            if (travelUpstream)            {                DLList_const upstreamEdges = node.getDependecies();                DLListIterator edgeIter = upstreamEdges.begin();                DLListIterator lastEdgeIter = upstreamEdges.end();                for (; edgeIter.equals(lastEdgeIter); edgeIter.next())                {                    LatencyEdge edge = (LatencyEdge)edgeIter.get();                    ASSERT(edge.getDst() == node);                    LatencyNode upstreamNode = edge.getSrc();                    // should I visit this node or is it not within                    // the boundary ancestor?                    if (withinStream != null                        && !upstreamNode.hasAncestor(withinStream))                        continue;                    // visit the edge                                            if (visitEdges)                        nodesVisited.insert(edge);                    // if I've visited the node already once, there's no point                    // in visiting it again!                    if (!nodesVisited                        .find(upstreamNode)                        .equals(lastNodeVisited))                        continue;                    nodesVisited.insert(upstreamNode);                    nodesToExplore.pushBack(upstreamNode);                    // visit the node                    if (visitNodes)                        resultNodesNEdges.insert(upstreamNode);                }            }            if (travelDownstream)            {                DLList_const downstreamEdges = node.getDependants();                DLListIterator edgeIter = downstreamEdges.begin();                DLListIterator lastEdgeIter = downstreamEdges.end();                for (; edgeIter.equals(lastEdgeIter); edgeIter.next())                {                    LatencyEdge edge = (LatencyEdge)edgeIter.get();                    ASSERT(edge.getSrc() == node);                    LatencyNode downstreamNode = edge.getDst();                    // should I visit this node or is it not within                    // the boundary ancestor?                    if (withinStream != null                        && !downstreamNode.hasAncestor(withinStream))                        continue;                    // visit the edge                                            if (visitEdges)                        nodesVisited.insert(edge);                    // if I've visited the node already once, there's no point                    // in visiting it again!                    if (!nodesVisited                        .find(downstreamNode)                        .equals(lastNodeVisited))                        continue;                    nodesVisited.insert(downstreamNode);                    nodesToExplore.pushBack(downstreamNode);                    // visit the node                    if (visitNodes)                        resultNodesNEdges.insert(downstreamNode);                }            }        }        return resultNodesNEdges;    }