Fix broken variables tree iteration.

This fixes whole number of problems with iterating through RB tree
containing variables. Especially:
https://dev.cfengine.com/issues/6033
https://dev.cfengine.com/issues/6779

EvalContextVariableTableIteratorNew is calling VariableTableIteratorNew
which is not aware of variable indexes (VarRef->indices). Then while picking
value form tree to be iterator it might or might not contain indexes.
Randomly selecting variable with wrong index (and number of indexes)
is causing wrong behavior while iterating through list of variables.
VariableTableIteratorNext is checking indexes and returning variables
based on VariableTableIterator selected previously by
EvalContextVariableTableIteratorNew which is totally unreliable in case
of arrays.
(cherry picked from commit e2c8cd0f2fb9724e47330ecaca7fdd452a7bc60a)

Conflicts:

	libpromises/evalfunction.c
Fix relaying on order of keys returned by maparray.
(cherry picked from commit e4809443a5b959f3166ea718df87792380733712)
Merge pull request #2042 from pasinskim/3.6.x

Redmine#6779 cherries