SELECT * FROM :table WHERE
company_id = :company_id
OR parent_id = (
SELECT id FROM :table WHERE company_id = :company_id)
OR parent_id IN (
SELECT id FROM :table WHERE parent_id = (
SELECT id FROM :table WHERE company_id = :company_id))