--
-- tree_ancestor_p/2
--
create or replace function tree_ancestor_p(
  bit varying,
  bit varying
) returns bool as $$

declare
  p_potential_ancestor      alias for $1;
  p_potential_child         alias for $2;
begin
  return position(p_potential_ancestor in p_potential_child) = 1;
end;$$ language plpgsql;