Path merge operation moved to external method. Fixed bug with nested 'g' tag