We should start with creating SQL Query
After that create Terms Query and include previous SQL results
Then apply this query in the listing for terms
If we need to retrieve all child terms of the parent term for the current post, we need to modify this part
This way we get parent's terms. Then we include this SQL query in Terms query in Parent field
And we should also add fallback