What type of issue are you facing now.? As per your requirement you need not worry about parentId and Id the main requirement is filter based on IsFavorite column obviously it should return the parent and child information.
EX:
select * from tablename
where IsFavorite= true
If this is not your expecting then please elaborate your requirement with some sample data.