function T = prod_pi_msgs_tabular(bnet, n, except)

ps = parents(bnet.adj_mat, n);
ns = bnet.node_sizes;
fam = [ps n];

if strcmp(bnet.algo, 'cutset')
  pp = bnet.pearl.phantom_parents{n};
  fam = union(fam, pp);
end

T = mk_table(fam, ns(fam)); % initializes to 1s
for i=1:length(ps)
  p = ps(i);
  if p ~= except
    pi_from_parent = mk_table(p, ns(p));
    pi_from_parent.T = bnet.pearl.msg{n}.pi_from_parent{i};
    T = multiply_by_table(T, pi_from_parent);
  end
end

if strcmp(bnet.algo, 'cutset')
  pp = bnet.pearl.phantom_parents{n};
  msg = bnet.pearl.phantom_msgs{n};
  assert(length(pp) <= 1);
  for i=1:length(pp)
    p = pp(i);
    pi_from_parent = mk_table(p, ns(p));
    pi_from_parent.T = msg;
    T = multiply_by_table(T, pi_from_parent);
  end  
end
