public int readTree(int tree[],int probability[]) {
            int i = 0; 

            /*
             * 1. pick corresponding probability probability[i >> 1]
             * 2. pick left or right branch from coded info decodeBool(probability)
             * 3. tree[i+decodedBool] get corresponding (left of right) value
             * 4. repeat until tree[i+decodedBool] is positive 
             */
            while ((i = tree[i + readBit(probability[i >> 1])]) > 0) {
            }
            return -i; /* negate the return value */

        }
public int readTree ( int tree [ ] , int probability [ ] ) { int i = 0 ; while ( ( i = tree [ i + readBit ( probability [ i > > 1 ] ) ] ) > 0 ) { } return - i ; }
General formula in VP8 trees.
<ul>
<li> if tree element is a positive number it is treated as index of the child elements <pre>tree[i] > 0</pre>
<ul>
<li> left child is assumed to have index <pre>i</pre> and value <pre>tree[i]</pre> </li>
<li> right child is assumed to have index <pre>i+1</pre> and value <pre>tree[i+1]</pre></li>
</ul>
</li>
<li> a negative tree value means a leaf node was reached and it's negated value should be returned <pre>-tree[i]</pre></li>
</ul>

Here's a real example of a tree coded according to this formula in VP8 spec.
<pre>
const tree_index mb_segment_tree [2 * (4-1)] =
// +-------+---+
// |       |   |
{ 2,  4, -0, -1, -2, -3 };
//     |           |   |
//     +-----------+---+
</pre>

If presented in hierarchical form this tree would look like:
<pre>
+---------------+
|      root     |
|     /    \    |
|    2      4   |
|   / \    / \  |
| -0  -1 -2  -3 |
+---------------+
<pre>

On the other hand probabilities are coded only for non-leaf nodes.
Thus tree array has twice as many nodes as probabilities array
Consider (3>>1) == 1 == (2>>1), and (0>>1) == 0 == (1>>1)
Thus single probability element refers to single parent element in tree.
if (using that probability) a '0' is coded, algorithm goes to the left
branch, correspondingly if '1' is coded, algorithm goes to
the right branch (see tree structure above).

The process is repeated until a negative tree element is found.