Any failure along a success branch after a node that has a failure node
should result in that failure nodes branch being executed. In order to
simplify the iteration through the tree, we link all failure nodes of
children of the success branch to the appropriate failure node. For
example,
3 -> 4 -> 5 -> 7 -> 9
|
| (failure)
\ /
6 -> 8 -> 10
becomes:
3 -> 4 -> 5 -> 7 -> 9
| | |
+----/-----/
|
\ /
6 -> 8 -> 10
Note: implementation based on Matt Nathan's Java port of the OpenCV Haar
code.