This could do the job:
select level0.level0, level1.level1, level2.level2, level3.level3
from (
select
row_number() over ( order by level0 ) as rownum,
level0
from dx
where level0 is not null and level1 is null
) level0
full outer join (
select
row_number() over ( order by level1 ) as rownum,
level1
from dx
where level1 is not null and level2 is null
) level1
on level1.rownum = level0.rownum
full outer join (
select
row_number() over ( order by level1 ) as rownum,
level2
from dx
where level2 is not null and level3 is null
) level2
on level2.rownum = coalesce( level0.rownum, level1.rownum )
full outer join (
select
row_number() over ( order by level1 ) as rownum,
level3
from dx
where level3 is not null
) level3
on level3.rownum = coalesce( level0.rownum, level1.rownum, level2.rownum )
order by coalesce( level0.rownum, level1.rownum, level2.rownum, level3.rownum );
This could do the job: