def get_processtree_pids(pid, include_parent=True):
 parents = get_all_processes_pids()
 all_pids = parents.keys()
 pids = set([pid])
 while True:
  pids_new = pids.copy()
  for _pid in all_pids:
   if (parents[_pid] in pids):
    pids_new.add(_pid)
  if (pids_new == pids):
   break
  pids = pids_new.copy()
 if (not include_parent):
  pids.remove(pid)
 return list(pids)

def get_processtree_pids ( pid , include_parent = True ) : parents = get_all_processes_pids ( ) all_pids = parents . keys ( ) pids = set ( [ pid ] ) while True : pids_new = pids . copy ( ) for _pid in all_pids : if ( parents [ _pid ] in pids ) : pids_new . add ( _pid ) if ( pids_new == pids ) : break pids = pids_new . copy ( ) if ( not include_parent ) : pids . remove ( pid ) return list ( pids )
return a list with all the pids of a process tree .