def __len__(self):
        '''
        The number of intervals maintained in the tree.
        Note that adding zero- or negative-size intervals does not affect its size (they are not registered).
        
        >>> t = IntervalTree(0, 100)
        >>> t.add_interval(1, 10)
        >>> t.add_interval(20, 30)
        >>> t.add_interval(20, 20)
        >>> t.add_interval(20, 19)
        >>> len(t)
        2
        '''
        
        if self.single_interval is None:
            return 0
        elif self.single_interval != 0:
            return 1
        else:
            size = len(self.mid_sorted_by_start)
            if self.left_subtree is not None:
                size += len(self.left_subtree)
            if self.right_subtree is not None:
                size += len(self.right_subtree)
            return size
def __len__ ( self ) : if self . single_interval is None : return 0 elif self . single_interval != 0 : return 1 else : size = len ( self . mid_sorted_by_start ) if self . left_subtree is not None : size += len ( self . left_subtree ) if self . right_subtree is not None : size += len ( self . right_subtree ) return size
The number of intervals maintained in the tree.
        Note that adding zero- or negative-size intervals does not affect its size (they are not registered).
        
        >>> t = IntervalTree(0, 100)
        >>> t.add_interval(1, 10)
        >>> t.add_interval(20, 30)
        >>> t.add_interval(20, 20)
        >>> t.add_interval(20, 19)
        >>> len(t)
        2