Method which finds child according to index. Applies only to nodes whose children are sorted into a dict,
    so if the current node's children are in a list it will recursively search - similarly if the index is not found
    in the current node's dictionary indexes.
    :param node: current node to search for
    :param index: index of child.
    :return:

def FindByIndex(node, index):
    '''
    Method which finds child according to index. Applies only to nodes whose children are sorted into a dict,
    so if the current node's children are in a list it will recursively search - similarly if the index is not found
    in the current node's dictionary indexes.
    :param node: current node to search for
    :param index: index of child.
    :return:
    '''
    result = None
    if isinstance(node.children, dict):
        result = node.GetChild(index)
        if result is None:
            children = list(node.children.keys())
            child = 0
            while child < len(children) and result is None:
                key = children[child]
                result = FindByIndex(node.GetChild(key), index)
                if result is not None:
                    break
                child += 1
    else:
        child = 0
        while child < len(node.children) and result is None:
            result = FindByIndex(node.GetChild(child), index)
            if result is not None:
                break
            child += 1
    return result