code: def numberofnetworks(self):
          
          sels1 = selectiontools.Selections()
          sels2 = selectiontools.Selections()
          complete = selectiontools.Selection('complete',
                                              self.nodes, self.elements)
          for node in self.endnodes:
              sel = complete.copy(node.name).select_upstream(node)
              sels1 += sel
              sels2 += sel.copy(node.name)
          for sel1 in sels1:
              for sel2 in sels2:
                  if sel1.name != sel2.name:
                      sel1 -= sel2
          for name in list(sels1.names):
              if not sels1[name].elements:
                  del sels1[name]
          return sels1
docs: The number of distinct networks defined by the|Node| and
          |Element| objects currently handled by the |HydPy| object.