code: def _load_location( self ):
          
          directories = {}
          files = {}
          root = PStatLocation( '/', 'PYTHONPATH' )
          self.location_rows = self.rows.copy()
          for child in self.rows.values():
              current = directories.get( child.directory )
              directory, filename = child.directory, child.filename
              if current is None:
                  if directory == '':
                      current = root
                  else:
                      current = PStatLocation( directory, '' )
                      self.location_rows[ current.key ] = current
                  directories[ directory ] = current
              if filename == '~':
                  filename = '<built-in>'
              file_current = files.get( (directory,filename) )
              if file_current is None:
                  file_current = PStatLocation( directory, filename )
                  self.location_rows[ file_current.key ] = file_current
                  files[ (directory,filename) ] = file_current
                  current.children.append( file_current )
              file_current.children.append( child )
          # now link the directories...
          for key,value in directories.items():
              if value is root:
                  continue
              found = False
              while key:
                  new_key,rest = os.path.split( key )
                  if new_key == key:
                      break
                  key = new_key
                  parent = directories.get( key )
                  if parent:
                      if value is not parent:
                          parent.children.append( value )
                          found = True
                          break
              if not found:
                  root.children.append( value )
          # lastly, finalize all of the directory records...
          root.finalize()
          return root
docs: Build a squaremap-compatible model for location-based hierarchy