diff --git a/CHANGELOG.md b/CHANGELOG.md
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,10 @@
 
 ## HEAD
 
+## 0.5.1
+
+- Fix bug (#59, #54) in DFS traversal order.
+
 ## 0.5.0
 
 - Split `scalpel` into two packages: `scalpel` and `scalpel-core`. The latter
diff --git a/scalpel-core.cabal b/scalpel-core.cabal
--- a/scalpel-core.cabal
+++ b/scalpel-core.cabal
@@ -1,5 +1,5 @@
 name:                scalpel-core
-version:             0.5.0
+version:             0.5.1
 synopsis:            A high level web scraping library for Haskell.
 description:
     Scalpel core provides a subset of the scalpel web scraping library that is
@@ -24,7 +24,7 @@
 source-repository this
   type:     git
   location: https://github.com/fimad/scalpel.git
-  tag:      v0.5.0
+  tag:      v0.5.1
 
 library
   other-extensions:
diff --git a/src/Text/HTML/Scalpel/Internal/Select.hs b/src/Text/HTML/Scalpel/Internal/Select.hs
--- a/src/Text/HTML/Scalpel/Internal/Select.hs
+++ b/src/Text/HTML/Scalpel/Internal/Select.hs
@@ -219,8 +219,8 @@
     | nodeMatches n info = (shrunkSpec :)
                          $ selectNodes [n] (tags, fs, ctx)
                          $ selectNodes [n] (tags, Tree.subForest f, ctx) acc
-    | otherwise          = selectNodes [n] (tags, fs, ctx)
-                         $ selectNodes [n] (tags, Tree.subForest f, ctx) acc
+    | otherwise          = selectNodes [n] (tags, Tree.subForest f, ctx)
+                         $ selectNodes [n] (tags, fs, ctx) acc
     where
         Span lo hi = Tree.rootLabel f
         shrunkSpec = (
diff --git a/tests/TestMain.hs b/tests/TestMain.hs
--- a/tests/TestMain.hs
+++ b/tests/TestMain.hs
@@ -296,6 +296,26 @@
                 index   <- position
                 content <- text anySelector
                 return (index, content))
+
+    ,   scrapeTest
+            "<div><p>p1</p><p>p2</p><blockquote><p>p3</p></blockquote><p>p4</p>"
+            (Just ["p1", "p2", "p3", "p4"])
+            (texts "p")
+
+    ,   scrapeTest
+            "<a><b>1</b></a><a><b>2</b></a><a><b>3</b></a>"
+            (Just ["1","2","3"])
+            (texts "a")
+
+    ,   scrapeTest
+            "<a><b>1</b></a><a><b>2</b></a><a><b>3</b></a>"
+            (Just ["1","2","3"])
+            (texts $ "a" // "b")
+
+    ,   scrapeTest
+            "<a><b>1</b></a><a><b>2</b></a><a><b>3</b></a>"
+            (Just ["1","2","3"])
+            (texts "b")
     ]
 
 scrapeTest :: (Eq a, Show a) => String -> Maybe a -> Scraper String a -> Test
