CBD-681: Improve tree searching

The tree can now be searched/traversed with a function. This is
needed in order to stop the traversal when a limit parameter is
specified.

Additional functions were added. One to traverse the full tree
without a given bounding box and another one that just returns
the number of elements (not the elements themselves) for a
specific query (or the full tree).

Change-Id: I68a68742f450ae5e72efc9265bbcad138ef6bd64
Reviewed-on: http://review.couchbase.org/22986
Tested-by: buildbot <build@couchbase.com>
Reviewed-by: Filipe David Borba Manana <fdmanana@gmail.com>
CBD-681: Make etap tests work with Apache CouchDB

Apache CouchDB doesn't have the couch_file_write_guard module,
hence enclose the call in a try/catch block.

Change-Id: I2139c9f1e99ce996b5fdc10da425fc0cb27397ed
Reviewed-on: http://review.couchbase.org/22987
Tested-by: buildbot <build@couchbase.com>
Reviewed-by: Filipe David Borba Manana <fdmanana@gmail.com>