Index: DepthFirstIterator.h
===================================================================
--- DepthFirstIterator.h	(revision 73222)
+++ DepthFirstIterator.h	(working copy)
@@ -72,23 +72,25 @@
   // VisitStack - Used to maintain the ordering.  Top = current block
   // First element is node pointer, second is the 'next child' to visit
   std::vector<std::pair<NodeType *, ChildItTy> > VisitStack;
+  NodeType* CurrentTopNode;
 private:
   inline df_iterator(NodeType *Node) {
     this->Visited.insert(Node);
-    VisitStack.push_back(std::make_pair(Node, GT::child_begin(Node)));
+    CurrentTopNode = Node;
   }
-  inline df_iterator() { /* End is when stack is empty */ }
+  inline df_iterator() { CurrentTopNode = 0; /* End is when stack is empty */ }
 
   inline df_iterator(NodeType *Node, SetType &S)
     : df_iterator_storage<SetType, ExtStorage>(S) {
     if (!S.count(Node)) {
       this->Visited.insert(Node);
-      VisitStack.push_back(std::make_pair(Node, GT::child_begin(Node)));
+      CurrentTopNode = Node;
     }
   }
   inline df_iterator(SetType &S)
     : df_iterator_storage<SetType, ExtStorage>(S) {
     // End is when stack is empty
+    CurrentTopNode = 0;
   }
 
 public:
@@ -108,13 +110,14 @@
   static inline _Self end(const GraphT& G, SetType &S) { return _Self(S); }
 
   inline bool operator==(const _Self& x) const {
-    return VisitStack.size() == x.VisitStack.size() &&
+    return CurrentTopNode == x.CurrentTopNode &&
+           VisitStack.size() == x.VisitStack.size() &&
            VisitStack == x.VisitStack;
   }
   inline bool operator!=(const _Self& x) const { return !operator==(x); }
 
   inline pointer operator*() const {
-    return VisitStack.back().first;
+    return CurrentTopNode ? CurrentTopNode : VisitStack.back().first;
   }
 
   // This is a nonstandard operator-> that dereferences the pointer an extra
@@ -124,7 +127,14 @@
   inline NodeType *operator->() const { return operator*(); }
 
   inline _Self& operator++() {   // Preincrement
+
+    if (CurrentTopNode != 0) {
+      VisitStack.push_back(std::make_pair(CurrentTopNode, GT::child_begin(CurrentTopNode)));
+      CurrentTopNode = 0;
+    }
+
     do {
+
       std::pair<NodeType *, ChildItTy> &Top = VisitStack.back();
       NodeType *Node = Top.first;
       ChildItTy &It  = Top.second;
@@ -134,7 +144,7 @@
         if (!this->Visited.count(Next)) {  // Has our next sibling been visited?
           // No, do it now.
           this->Visited.insert(Next);
-          VisitStack.push_back(std::make_pair(Next, GT::child_begin(Next)));
+          CurrentTopNode = Next;
           return *this;
         }
       }
