def get_children(self, recursive=False):
if not self.is_running():<EOL><INDENT>name = self._platform_impl._process_name<EOL>raise NoSuchProcess(self.pid, name)<EOL><DEDENT>ret = []<EOL>if not recursive:<EOL><INDENT>for p in process_iter():<EOL><INDENT>try:<EOL><INDENT>if p.ppid == self.pid:<EOL><INDENT>if self.create_time <= p.create_time:<EOL><INDENT>ret.append(p)<EOL><DEDENT><DEDENT><DEDENT>except NoSuchProcess:<EOL><INDENT>pass<EOL><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>table = defaultdict(list)<EOL>for p in process_iter():<EOL><INDENT>try:<EOL><INDENT>table[p.ppid].append(p)<EOL><DEDENT>except NoSuchProcess:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>checkpids = [self.pid]<EOL>for pid in checkpids:<EOL><INDENT>for child in table[pid]:<EOL><INDENT>try:<EOL><INDENT>intime = self.create_time <= child.create_time<EOL><DEDENT>except NoSuchProcess:<EOL><INDENT>pass<EOL><DEDENT>else:<EOL><INDENT>if intime:<EOL><INDENT>ret.append(child)<EOL>if child.pid not in checkpids:<EOL><INDENT>checkpids.append(child.pid)<EOL><DEDENT><DEDENT><DEDENT><DEDENT><DEDENT><DEDENT>return ret<EOL>
Return the children of this process as a list of Process
        objects.
        If recursive is True return all the parent descendants.

        Example (A == this process):

         A ─┐
            │
            ├─ B (child) ─┐
            │             └─ X (grandchild) ─┐
            │                                └─ Y (great grandchild)
            ├─ C (child)
            └─ D (child)

        >>> p.get_children()
        B, C, D
        >>> p.get_children(recursive=True)
        B, X, Y, C, D

        Note that in the example above if process X disappears
        process Y won't be returned either as the reference to
        process A is lost.