Fixed bug in 'exists' function which checked the whole tree instead of just the correct branches.