There is no way you can actually delete a data source from query. Consider disabling data sources (QueryBuildDataSource::enabled(false) method). That will give the same result as removing a data source and all of its children from query.
If it's not applicable you can try to build a copy of query skiping unwanted data sources. You may find SysQuery::packRangeAndSortOrder() and SysQuery::unpackRangeAndSortorder() methods useful while implementing that.