new version which supports nested populations

Signed-off-by: Alexander Knapstein <alexander.knapstein@inspirationlabs.com>