(1)   for all element that is operated do
(2)  operation
(3)  for all operation in operation list do
(4)  if   does not operate on   then
(5)     continue inner iteration
(6)  else if    then
(7)     
(8)  else if    then
(9)     
(10) else
(11)     combine and
(12)     
(13) end if
(14)end for
(15) end for
Algorithm 1: Removing redundant primitive operations.