Who is the rightful ruler? Who will rule the realm?

You are given a family tree which contains: name, sex, date of birth, date of death and a list of heirs, for each family member. You may use any convenient (nested) list format to represent the tree. The following examples will use JSON. Determine who will rule the realm and in which order.
The succession rules are the following:


When a king dies the realm goes to its oldest legit male child.
If there is none it passes to the oldest legit female child.
In case the king had no heirs the realm goes to the oldest legit king's brother
If there are no male brothers the realm will go to the oldest legit king's sister
If all legit relatives are dead the realm goes to the closest bastard, applying the above rules
If no legit nor bastard relatives are alive print LINE EXTINCT


We define a legit son as one who has the same "house" name as its father.

Examples:

Input
{}

Output
LINE EXTINCT

Input

{
    "name" : "Maegor",
    "house" : "Targaryen",
    "birth" : 12,
    "death" : 48,
    "sex" : "male",
    "heirs" : []
}


Output 12-48: Maegor, LINE EXTINCT

Input

{
    "name" : "Jaehaerys",
    "house" : "Targaryen",
    "birth" : 34,
    "death" : 103,
    "sex" : "male",
    "heirs" : [
        {
        "name" : "Viserys",
        "house" : "Targaryen",
        "birth" : 77,
        "death" : 129,
        "sex" : "male",
        "heirs" : []
        }
    ]
}


Output 34-103: Jaehaerys, 103-129: Viserys, LINE EXTINCT

Input

{
        "name" : "Eddard",
        "house" : "Stark",
        "birth" : 263,
        "death" : 299,
        "sex" : "male",
        "heirs" : [
            {
            "name" : "Robb",
            "house" : "Stark",
            "birth" : 283,
            "death" : 300,
            "sex" : "male",
            "heirs" : []
            },
            {
             "name" : "Jon",
             "house" : "Snow",
             "birth" : 284,
             "death" : 384,
             "sex" : "male",
             "heirs" : []
            },
            {
             "name" : "Sansa",
             "house" : "Stark",
             "birth" : 286,
             "death" : 320,
             "sex" : "female",
             "heirs" : []
            },
            {
             "name" : "Arya",
             "house" : "Stark",
             "birth" : 289,
             "death" : 350,
             "sex" : "female",
             "heirs" : []
            },

            {
             "name" : "Brann",
             "house" : "Stark",
             "birth" : 290,
             "death" : 315,
             "sex" : "male",
             "heirs" : []
            },
            {
             "name" : "Rickon",
             "house" : "Stark",
             "birth" : 295,
             "death" : 319,
             "sex" : "male",
             "heirs" : []
            }

        ]
    }


Output: 263-299: Eddard, 299-300: Robb, 300-315: Brann, 315-319: Rickon, 319-320: Sansa, 320-350: Arya, 350-384: Jon, LINE EXTINCT

Note that the output can be formatted in any way you wish, its only requirements is that it contains the time of reign and the name of the reigning king during those years.
I've used kings from the ASOIAF as demonstrative example, however the code needs to be valid for all input.

You may assume that no twins will be born.

This is a code golf challenge, so the shortest code in bytes wins

Good luck!!!
PHP, 664 bytes

I'm not sure if 664 bytes fit for code golfing, but here it is:

$k=json_decode($argv[1]);$s=[];$f='array_shift';$r='heirs';$e='death';$y='year';function s
($k,&amp;$e){uasort($e,function($a,$b)use($k){$c=$a-&gt;{$h='house'};$d=$b-&gt;$h;$e=$k-&gt;$h;if($c==$e
&amp;&amp;$d!=$e)return-1;elseif($c!=$e&amp;&amp;$d==$e)return 1;elseif($a-&gt;sex&lt;$b-&gt;sex)return 1;elseif($a
-&gt;sex&gt;$b-&gt;sex)return -1;else return$a-&gt;birth-$b-&gt;birth;});}function d(&amp;$e,$y){foreach($e 
as$i=&gt;$h)if($h-&gt;death&lt;=$y)unset($e[$i]);};($x=(array)$k)&amp;&amp;$k-&gt;$y=$k-&gt;birth;$l=[];while($x)
{$l[]=$k;$z=$k-&gt;$e;s($k,$k-&gt;$r);d($k-&gt;$r,$k-&gt;$e);if($k-&gt;$r){$s=$k-&gt;$r;$k=$f($s);}else{s($k
,$s);d($s,$k-&gt;$e);$k=$f($s);}if(!$k)break;$k-&gt;$y=$z;}foreach($l as$k)
echo"{$k-&gt;$y}-{$k-&gt;$e}: $k-&gt;name, ";echo"LINE EXTINCT";


It receives the JSON string input as the first command line argument.

The algorithm follows the steps described in the challenge (starts from the king, then sorts the heirs and then the siblings to find the next king).

Demo