Custom filter export with group association

Hi there,
I just started using jabref, and it’s great indeed!
I managed to create (well, copy and modify as required) a custom filter to export entries with relative comments/reviews.
What I would need now is a way (if possible) to export the group name(s) to which the entry belongs. Even better if I could actually sort (structure) the exported entries by groups, similarly to what I see in the groups tree.

Example:
my entries:
+entry#1
+entry#2
+entry#3
+entry#4

my groups:
group#1 [entry#1, entry#2, entry#4]
subgroup#1.1 [entry#1]
subgroup#1.2 [entry#2, entry#4]
group#2 [entry#1, entry#3]

my ideal export:
group#1
subgroup#1.1
entry#1 {fields}
subgroup#1.2
entry#2 {fields}
entry#4 {fields}
group#2
entry#1 {fields}
entry#3 {fields}

not an issue if there are repetitions. Any tips how to achieve this?
Thanks in advance.

Cheers,
Gino