Binary search tree and duck-duck-goose array problem