code: def calculate_totals( self, children, local_children=None ):
          
          for field,local_field in (('recursive','calls'),('cumulative','local')):
              values = []
              for child in children:
                  if isinstance( child, PStatGroup ) or not self.LOCAL_ONLY:
                      values.append( getattr( child, field, 0 ) )
                  elif isinstance( child, PStatRow ) and self.LOCAL_ONLY:
                      values.append( getattr( child, local_field, 0 ) )
              value = sum( values )
              setattr( self, field, value )
          if self.recursive:
              self.cumulativePer = self.cumulative/float(self.recursive)
          else:
              self.recursive = 0
          if local_children:
              for field in ('local','calls'):
                  value = sum([ getattr( child, field, 0 ) for child in children] )
                  setattr( self, field, value )
              if self.calls:
                  self.localPer = self.local / self.calls
          else:
              self.local = 0
              self.calls = 0
              self.localPer = 0
docs: Calculate our cumulative totals from children and/or local children