Fix parent / children index calculation logic

Previous index calculation formulas used where right for an array whose
first element index is 1.
They have been adapted to an array whose first element index is 0.