Unfortunately there has been no sample data provided and there can be only speculation.
So here is an example that includes only one table:
-- made up data
with t1(id1, parent_id, name1) as(
select 1, null, 'name_1' from dual union all
select 2, 1, 'name_2' from dual union all
select 3, 2, 'name_3' from dual union all
select 4, 2, 'name_4' from dual
), tree as ( -- hierarchical query
select id1
, parent_id
, concat(lpad('-', level * 3, '-'), name1) as node_name
, connect_by_isleaf is_leaf
from t1
start with parent_id is null
connect by prior id1 = parent_id
)
select node_name
from tree
Which will give us:
NODE_NAME
-----------------
---name_1
------name_2
---------name_3
---------name_4
In order to display full hierarchy for each leaf, we start building our sub-trees starting from
a leaf and going all the way up to the root:
select node_name
, row_number() over(partition by connect_by_root(t.id1)
order by id1) as subtree_rn
from tree t
start with is_leaf = 1
connect by id1 = prior parent_id
Result:
NODE_NAME SUBTREE_RN
-----------------------------------
---name_1 1
------name_2 2
---------name_3 3
---name_1 1
------name_2 2
---------name_4 3