Index: DepthFirstIterator.h
===================================================================
--- DepthFirstIterator.h	(revision 74420)
+++ DepthFirstIterator.h	(working copy)
@@ -72,25 +72,53 @@
   // 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() { 
+    // End is when stack is empty and CurrentTopNode is 0
+    CurrentTopNode = 0; 
+  }
   inline df_iterator(NodeType *Node, SetType &S)
     : df_iterator_storage<SetType, ExtStorage>(S) {
-    if (!S.count(Node)) {
+    CurrentTopNode = S.count(Node) ? 0 : Node;
+    if (CurrentTopNode) {
       this->Visited.insert(Node);
-      VisitStack.push_back(std::make_pair(Node, GT::child_begin(Node)));
     }
   }
   inline df_iterator(SetType &S)
     : df_iterator_storage<SetType, ExtStorage>(S) {
     // End is when stack is empty
+    CurrentTopNode = 0;
   }
 
+  inline void toNext() {
+    do {
+      std::pair<NodeType *, ChildItTy> &Top = VisitStack.back();
+      NodeType *Node = Top.first;
+      ChildItTy &It  = Top.second;
+
+      while (It != GT::child_end(Node)) {
+        NodeType *Next = *It++;
+        // Has our next sibling been visited?
+        if (Next && !this->Visited.count(Next)) {  
+          // No, do it now.
+          this->Visited.insert(Next);
+          CurrentTopNode = Next;
+          return;
+        }
+      }
+
+      // Oops, ran out of successors... go up a level on the stack.
+      VisitStack.pop_back();
+    } while (!VisitStack.empty());
+
+    CurrentTopNode = 0;
+  }
+
 public:
   typedef typename super::pointer pointer;
   typedef df_iterator<GraphT, SetType, ExtStorage, GT> _Self;
@@ -108,13 +136,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;
   }
 
   // This is a nonstandard operator-> that dereferences the pointer an extra
@@ -124,24 +153,20 @@
   inline NodeType *operator->() const { return operator*(); }
 
   inline _Self& operator++() {   // Preincrement
-    do {
-      std::pair<NodeType *, ChildItTy> &Top = VisitStack.back();
-      NodeType *Node = Top.first;
-      ChildItTy &It  = Top.second;
+    VisitStack.push_back(std::make_pair(CurrentTopNode, 
+                                        GT::child_begin(CurrentTopNode)));
+    toNext();
+    return *this;
+  }
 
-      while (It != GT::child_end(Node)) {
-        NodeType *Next = *It++;
-        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)));
-          return *this;
-        }
-      }
-
-      // Oops, ran out of successors... go up a level on the stack.
-      VisitStack.pop_back();
-    } while (!VisitStack.empty());
+  // skips all children of the current node and traverses to next node
+  //
+  inline _Self& skipChildren() {  
+    if (!VisitStack.empty()) {
+      toNext();
+    } else {
+      CurrentTopNode = 0;
+    }
     return *this;
   }
 
Index: PostOrderIterator.h
===================================================================
--- PostOrderIterator.h	(revision 74420)
+++ PostOrderIterator.h	(working copy)
@@ -56,7 +56,7 @@
   void traverseChild() {
     while (VisitStack.top().second != GT::child_end(VisitStack.top().first)) {
       NodeType *BB = *VisitStack.top().second++;
-      if (!this->Visited.count(BB)) {  // If the block is not visited...
+      if (BB && !this->Visited.count(BB)) {  // If the block is not visited...
         this->Visited.insert(BB);
         VisitStack.push(std::make_pair(BB, GT::child_begin(BB)));
       }
@@ -64,15 +64,17 @@
   }
 
   inline po_iterator(NodeType *BB) {
-    this->Visited.insert(BB);
-    VisitStack.push(std::make_pair(BB, GT::child_begin(BB)));
-    traverseChild();
+    if (BB) {
+      this->Visited.insert(BB);
+      VisitStack.push(std::make_pair(BB, GT::child_begin(BB)));
+      traverseChild();
+    }
   }
   inline po_iterator() {} // End is when stack is empty.
 
   inline po_iterator(NodeType *BB, SetType &S) :
-    po_iterator_storage<SetType, ExtStorage>(&S) {
-    if(!S.count(BB)) {
+    po_iterator_storage<SetType, ExtStorage>(S) {
+    if(BB && !S.count(BB)) {
       this->Visited.insert(BB);
       VisitStack.push(std::make_pair(BB, GT::child_begin(BB)));
       traverseChild();
@@ -80,7 +82,7 @@
   }
 
   inline po_iterator(SetType &S) :
-      po_iterator_storage<SetType, ExtStorage>(&S) {
+      po_iterator_storage<SetType, ExtStorage>(S) {
   } // End is when stack is empty.
 public:
   typedef typename super::pointer pointer;
