Nested aggregations not bringing any result

Hello,
I'm working on an algorithm that will generate an Elasticsearch query. In this algorithm nested aggregations may be produced.
In some cases, the nested aggregations does not produce any results.

Here's the sample mapping and data:

http://pastebin.com/U9TaqxNJ

My algorithm is generating the following query:

http://pastebin.com/tbJQaYQA

The result is the following:

http://pastebin.com/bcQ3Jwww

But I really think it should be something like:

http://pastebin.com/QANGpSLE

The sub2_nested aggregation has 0 documents, but I think it should have 2 documents (t1 and t2).
If I manually remove the sub2_nested aggregation (moving sub2 aggregation up) I can have the desired result.

The question is: does a nested aggregation mess up with another one?

Thanks!