ANother slow attempt at maintaining a sorted list/tree