[MRG] fix handling of empty trees