with cte as (
select p.id, p.parent_id, o.name from page p
left join page_options po on po.page_id = p.id
left join options o on o.id = po.option_id
)
select coalesce(o.name, (select o.name from cte where id = cte.parent_id) ) from cte
where id = :ID