def _extend_condensed_tree(tree, neighbor_indices, neighbor_distances, core_distances, min_samples):
    '\n    Create a new condensed tree with an additional point added, allowing for\n    computations as if this point had been part of the original tree. Note\n    that this makes as little change to the tree as possible, with no\n    re-optimizing/re-condensing so that the selected clusters remain\n    effectively unchanged.\n\n    Parameters\n    ----------\n    tree : structured array\n        The raw format condensed tree to update.\n\n    neighbor_indices : array (2 * min_samples, )\n        An array of raw distance based nearest neighbor indices.\n\n    neighbor_distances : array (2 * min_samples, )\n        An array of raw distances to the nearest neighbors.\n\n    core_distances : array (n_samples, )\n        An array of core distances for all points\n\n    min_samples : int\n        The min_samples value used to generate core distances.\n\n    Returns\n    -------\n    new_tree : structured array\n        The original tree with an extra row providing the parent cluster\n        and lambda information for a new point given index -1.\n    '
    tree_root = tree['parent'].min()
    (nearest_neighbor, lambda_) = _find_neighbor_and_lambda(neighbor_indices, neighbor_distances, core_distances, min_samples)
    neighbor_tree_row = get_tree_row_with_child(tree, nearest_neighbor)
    potential_cluster = neighbor_tree_row['parent']
    if (neighbor_tree_row['lambda_val'] <= lambda_):
        new_tree_row = (potential_cluster, (- 1), 1, neighbor_tree_row['lambda_val'])
    else:
        while ((potential_cluster > tree_root) and (tree[(tree['child'] == potential_cluster)]['lambda_val'] >= lambda_)):
            potential_cluster = tree['parent'][(tree['child'] == potential_cluster)][0]
        new_tree_row = (potential_cluster, (- 1), 1, lambda_)
    return np.append(tree, new_tree_row)
Create a new condensed tree with an additional point added, allowing for
computations as if this point had been part of the original tree. Note
that this makes as little change to the tree as possible, with no
re-optimizing/re-condensing so that the selected clusters remain
effectively unchanged.

Parameters
----------
tree : structured array
    The raw format condensed tree to update.

neighbor_indices : array (2 * min_samples, )
    An array of raw distance based nearest neighbor indices.

neighbor_distances : array (2 * min_samples, )
    An array of raw distances to the nearest neighbors.

core_distances : array (n_samples, )
    An array of core distances for all points

min_samples : int
    The min_samples value used to generate core distances.

Returns
-------
new_tree : structured array
    The original tree with an extra row providing the parent cluster
    and lambda information for a new point given index -1.
def _extend_condensed_tree(tree, neighbor_indices, neighbor_distances, core_distances, min_samples):
    '\n    Create a new condensed tree with an additional point added, allowing for\n    computations as if this point had been part of the original tree. Note\n    that this makes as little change to the tree as possible, with no\n    re-optimizing/re-condensing so that the selected clusters remain\n    effectively unchanged.\n\n    Parameters\n    ----------\n    tree : structured array\n        The raw format condensed tree to update.\n\n    neighbor_indices : array (2 * min_samples, )\n        An array of raw distance based nearest neighbor indices.\n\n    neighbor_distances : array (2 * min_samples, )\n        An array of raw distances to the nearest neighbors.\n\n    core_distances : array (n_samples, )\n        An array of core distances for all points\n\n    min_samples : int\n        The min_samples value used to generate core distances.\n\n    Returns\n    -------\n    new_tree : structured array\n        The original tree with an extra row providing the parent cluster\n        and lambda information for a new point given index -1.\n    '
    tree_root = tree['parent'].min()
    (nearest_neighbor, lambda_) = _find_neighbor_and_lambda(neighbor_indices, neighbor_distances, core_distances, min_samples)
    neighbor_tree_row = get_tree_row_with_child(tree, nearest_neighbor)
    potential_cluster = neighbor_tree_row['parent']
    if (neighbor_tree_row['lambda_val'] <= lambda_):
        new_tree_row = (potential_cluster, (- 1), 1, neighbor_tree_row['lambda_val'])
    else:
        while ((potential_cluster > tree_root) and (tree[(tree['child'] == potential_cluster)]['lambda_val'] >= lambda_)):
            potential_cluster = tree['parent'][(tree['child'] == potential_cluster)][0]
        new_tree_row = (potential_cluster, (- 1), 1, lambda_)
    return np.append(tree, new_tree_row)