Custom grouping by taxonomy term in view I made a view with taxonomy and nodes, groupped like this:

term 1
    subterm 1
        row
        row
term 2
    subterm 1
        row
        row
term 3
    subterm 1
        row
        row
    subterm 2
        row
        row
term 4
    subterm 1
        row
        row


But I need grouping by term like this:

term 1
    row
    row
term 2
    row
    row
term 3
    subterm 1
        row
        row
    subterm 2
        row
        row
term 4
    row
term 5
    row
    etc.


please any ideas, i wasted a lot of time to find the hook and tpl.php for this (tpl. or hooks - ?)
Groping things in view not that easy, and what i suggest you here to save your time to use views_field_view which allowed you to insert view inside view.

So simply make 3 displays each one for level and pass the argument between them, that should not take more than 5 min