Query builder properly creating parent nodes