A tree map algorithm