Print process chains and command lines:

#!/usr/bin/env python3

import sys,os,os.path

pids = [pid for pid in os.listdir('/proc') if pid.isdigit()]

class Pid:
    def __init__(self,pid,cmdline,status,**kw):
        self.pid = pid
        self.cmdline = cmdline
        self.status = status
        self.__dict__.update(kw)
    def __getattr__(self,a):
        if a in self.status:
            return self.status[a]
        else:
            raise AttributeError(a)

def pdetails(x):
    # take a pid, get cmdline and status
    d = {}
    try:
        c = open("/proc/{}/cmdline".format(x)).read()
        s = open("/proc/{}/status".format(x)).read()
        cc = c.split("\000")
        a = s.strip().split("\n")
        for y in a:
            i,j = y.split(":")
            j = j.strip()
            d[i] = j
        return Pid(x,cc,d)
    except:
        return None

pidds = list(map(pdetails,pids))
pidds = list(filter(lambda t: t is not None, pidds))
pidd = {t.pid: t for t in pidds}

import re
for x in sys.argv[1:]:
    print("Finding {}".format(x))
    r = re.compile(x)
    for y in pidds:
        n = y.Name
        if r.search(n):
            print("Found pid: {}, name: {} for: {}".format(y.pid,n,x))
            t = y.pid
            while t in pidd:
                z = pidd[t]
                print("{:>6d}: {}".format(int(z.pid)," ".join(z.cmdline)))
                t = z.PPid
            print("Done chain for pid: {}\n".format(y.pid))
    print("Done finding {}\n".format(x))