   f float;
   c text;
   r record;
+  r1 record;
   sel pgmapcss_selector;
+  sel1 pgmapcss_selector;
   ob pgmapcss_selector_part;
+  ob1 pgmapcss_selector_part;
   where_selectors pgmapcss_selector[];
+  assignments hstore := ''::hstore;
+  k text;
 begin
   for r in select unnest(stat.selectors) selectors, unnest(stat.properties) properties loop
     -- TODO: make list of match-relevant tags configurable

    end if;
  end loop;

  -- get all used scale_denominators
  foreach sel in array where_selectors loop
    ob := sel.object;

    f := coalesce(ob.min_scale, 0);

	end if;

      end if;

      -- include selectors which are referenced through set-statement
      foreach r in array ob.conditions loop
	if assignments ? (quote_nullable(r.key) || '=>*') then
	  k := assignments->(quote_nullable(r.key) || '=>*');

	  foreach c in array string_to_array(substring(k, 2), ';') loop
	    sel1 := (stat.selectors)[cast(c as int)];
	    ob1 := sel1.object;
	    c := '(' || pgmapcss_compile_conditions(ob1.conditions) || ')';

	    if h ? ob1.type then
	      h := h || hstore(ob1.type, h->(ob1.type) || ' or ' || c);
	    else
	      h := h || hstore(ob1.type, c);
	    end if;
	  end loop;
	end if;
      end loop;
    end loop;

    ret := ret || E'  if render_context.scale_denominator >= ' || f || E' then\n';
