Factor out subselect from nodes_from_relations
Factor out subselect from ways_from_relations