Efficient handling of large sets of tuples with sharing trees