  pidtree(ppid, {advanced: true}, function(err, list) {
    if (err) {
      console.error(err.message);
      return;
    }

    var parents = {}; // Hash Map of parents
    var tree = {}; // Adiacency Hash Map
    while (list.length > 0) {
      var e = list.pop();
      if (tree[e.ppid]) {
        tree[e.ppid].push(e.pid);
      } else {
        tree[e.ppid] = [e.pid];
      }

      if (ppid === -1) {
        parents[e.pid] = e.ppid;
      }
    }

    var roots = [ppid];
    if (ppid === -1) {
      // Get all the roots
      roots = Object.keys(tree).filter(node => parents[node] === undefined);
    }

    roots.forEach(root => print(tree, root));
  });