 $$
 LANGUAGE SQL;
 
-CREATE OR REPLACE FUNCTION get_root_standards(standard_asn_id CHAR(8))
+CREATE OR REPLACE FUNCTION get_root_standards_nodes(standard_asn_id CHAR(8))
   RETURNS SETOF standards_nodes AS $$
 
   SELECT * FROM standards_nodes WHERE parent_asn_id LIKE 'D%';

$$
LANGUAGE SQL;

WITH RECURSIVE tree AS (
  SELECT node_id, ARRAY[]::integer[] AS ancestors
  FROM nodes WHERE parent_id IS NULL

  UNION ALL

  SELECT nodes.node_id, tree.ancestors || nodes.parent_id
  FROM nodes, tree
  WHERE nodes.parent_id = tree.node_id
) SELECT unnest(ancestors) FROM tree WHERE node_id = 15;

CREATE OR REPLACE FUNCTION get_ancestor_standard_nodes(standard_asn_id CHAR(8))
  RETURNS SETOF standards_nodes AS $$
    WITH RECURSIVE tree AS (
    SELECT
      asn_id,


CREATE OR REPLACE FUNCTION get_ancestor_asn_ids(standard_asn_id CHAR(8))
  RETURNS bpchar[] AS $$

   WITH RECURSIVE tree AS (
    SELECT
      asn_id,
