def FindPosition(node, addition, index=0):
    '''
    Method to search for children according to their position in list. Similar functionality to above method,
    except this is for adding items to the tree according to the nodes limits on children or types of children they can have
    :param node: current node being searched
    :param addition: the thing being added
    :param index: index to search
    :return:
    '''
    if node is None:
        return None
    if type(addition) in node.rules:
        if len(node.children) < node.limit or node.limit == 0:
            return node
        else:
            if len(node.children) == 0:
                return None
            indexes = node.GetChildrenIndexes()
            result = FindPosition(
                node.GetChild(
                    indexes[index]),
                addition,
                index)
            if result is None:
                index += 1
            child = 0
            while result is None and child < len(indexes):
                result = FindPosition(
                    node.GetChild(
                        indexes[child]),
                    addition,
                    index)
                child += 1
            return result
    else:
        if len(node.children) == 0:
            return None
        indexes = node.GetChildrenIndexes()
        result = FindPosition(node.GetChild(indexes[index]), addition, index)
        if result is None:
            index += 1
        child = 0
        while result is None and child < len(node.children):
            result = FindPosition(
                node.GetChild(
                    indexes[child]),
                addition,
                index)
            child += 1
        return result