implemented by tree data structure