def check_tree(F, p, tree, obj_seq, add_pos):
    """Check tree for tree-based non-dominated sorting."""
    if tree is None:
        return True

    N, M = F.shape

    # find the minimal index m satisfying that p[obj_seq[tree.root][m]] < tree.root[obj_seq[tree.root][m]]
    m = 0
    while m < M - 1 and F[p, obj_seq[tree.key, m]] >= F[tree.key, obj_seq[tree.key, m]]:
        m += 1

    # if m not found
    if m == M - 1:
        # p is dominated by the solution at the root
        return False
    else:
        for i in range(m + 1):
            # p is dominated by a solution in the branch of the tree
            if not check_tree(F, p, tree.children[i], obj_seq, i == m and add_pos):
                return False

        if tree.children[m] is None and add_pos:
            # add p to the branch of the tree
            tree.children[m] = Tree(key=p, num_branch=M - 1)
        return True
Check tree for tree-based non-dominated sorting.
pymoo/functions/standard/non_dominated_sorting.py