Nested set model: retrieve sub-tree containing nodes that match condition
The nested set model makes this kind of queries, for unlimited levels, easy to write:

SELECT *
FROM sr_projects
WHERE name LIKE '%x%'

UNION ALL

SELECT p.*                                 -- the parents
FROM sr_projects AS p
  JOIN 
    ( SELECT lft
      FROM sr_projects
      WHERE name LIKE '%x%'
    ) AS x
    ON p.lft &lt; x.lft AND x.lft &lt; p.rght

UNION ALL

SELECT ch.*                                -- the children
FROM sr_projects AS ch
  JOIN 
    ( SELECT lft, rght
      FROM sr_projects
      WHERE name LIKE '%x%'
    ) AS x
    ON x.lft &lt; ch.lft AND ch.lft &lt; x.rght ;


Test at SQLfiddle-1



It might be more efficient if you use a temp table, because the subquery with the unsargable condition (name LIKE '%x%') will only be run once. But that depends on the version of MySQL you are using. Some newer versions are capable of subquery optimizations (and can actually cache and reuse the subquery results and even automatically index them):

CREATE TEMPORARY TABLE temp_x AS
SELECT *
FROM sr_projects
WHERE name LIKE '%x%' ;


and then:

SELECT *
FROM temp_x

UNION ALL

SELECT p.*                                 -- the parents
FROM sr_projects AS p
  JOIN 
    temp_x AS x
    ON p.lft &lt; x.lft AND x.lft &lt; p.rght

UNION ALL

SELECT ch.*                                -- the children
FROM sr_projects AS ch
  JOIN 
    temp_x AS x
    ON x.lft &lt; ch.lft AND ch.lft &lt; x.rght ;

DROP TABLE temp_x ;


Test at SQLfiddle-2