(bug 64186) Decrease exhausing memory usage, speed up processing

update and synchronized from/with core

- delete local list after we are done with it
- decrease processing speed: list.remove() consumes a lot of time
  because lists are not indexed and removing an item  needs to
  search inside the sequence. There is an easy way for more speed
  when the parent category is just skipped inside the loop. This
  decreasea time consumtion by 65% with depth:3.

Change-Id: I5117a9d6071ab7f9d069b870f1a3e158274965ca
Merge "(bug 64186) Decrease exhausing memory usage, speed up processing"