Implement next-error and previous-error functionality for sparse trees