function pi = compute_pi_tabular(bnode, bnet)

pearl = bnet.pearl;
n = bnode.self;

% Pearl p183 eq 4.51
T = prod_pi_msgs_tabular(bnet, n, -1); % -1 means exclude none of the parents
if pearl.maximize
  CPT = mk_max_table_from_bnode(bnode);
else
  CPT = mk_table_from_bnode(bnode);
end

if 0&strcmp(bnet.algo, 'cutset')
  fam = [bnode.parents bnode.self];
  obs_fam = intersect(fam, bnet.cutset.instantiated_nodes);
  vals = bnet.cutset.instantiation(obs_fam);
  ns = bnet.node_sizes;
  ns(obs_fam) = 1;
  map = find_equiv_posns(obs_fam, fam);
  index = mk_multi_index(length(fam), map, vals);
  CPT = myreshape(CPT(index{:}), ns(fam));
end

T =  multiply_by_potential(T, CPT);
pi = marginalize_potential(T, n);
pi = pi.T(:);
