# Path: craft_ai/errors.py
# class CraftAiError(Exception):
#     """Base class for exceptions in the craft ai client."""
# 
#     def __init__(self, message=None, metadata=None):
#         self.message = message
#         self.metadata = metadata
#         super(CraftAiError, self).__init__(message, metadata)
# 
#     def __str__(self):
#         return repr(self.message)


from copy import copy
from .errors import CraftAiError
    return neighbours


def extract_output_tree(tree, output_property=None):
    """
    Extract the output decision tree specific for a given output property from a full decision tree.

    This function accepts trees as retrieved from `craft_ai.Client.get_generator_decision_tree`.

    Parameters:
        tree: A tree.
        output_property (optional): If provided, the output property for which the tree predicts
            values, otherwise the first defined tree is retrieved.
    """
    if not isinstance(tree, dict):
        raise CraftAiError(
            """Unable to retrieve the output tree, """
            """the given decision tree format is not a valid, expected a 'dict' got a {}.""".format(
                type(tree)
            )
        )
    if "trees" not in tree:
        raise CraftAiError(
            """Unable to retrieve the output tree, """
            """the given decision tree format is not a valid, no 'trees' property defined."""
        )
    trees = tree["trees"]
    if not output_property:
        output_property = list(trees)[0]
    if output_property not in trees:

# Path: craft_ai/errors.py
# class CraftAiError(Exception):
#     """Base class for exceptions in the craft ai client."""
# 
#     def __init__(self, message=None, metadata=None):
#         self.message = message
#         self.metadata = metadata
#         super(CraftAiError, self).__init__(message, metadata)
# 
#     def __str__(self):
#         return repr(self.message)


# Path: craft_ai/tree_utils.py
from copy import copy
from .errors import CraftAiError

    return neighbours


def extract_output_tree(tree, output_property=None):
    """
    Extract the output decision tree specific for a given output property from a full decision tree.

    This function accepts trees as retrieved from `craft_ai.Client.get_generator_decision_tree`.

    Parameters:
        tree: A tree.
        output_property (optional): If provided, the output property for which the tree predicts
            values, otherwise the first defined tree is retrieved.
    """
    if not isinstance(tree, dict):
        raise CraftAiError(
            """Unable to retrieve the output tree, """
            """the given decision tree format is not a valid, expected a 'dict' got a {}.""".format(
                type(tree)
            )
        )
    if "trees" not in tree:
        raise CraftAiError(
            """Unable to retrieve the output tree, """
            """the given decision tree format is not a valid, no 'trees' property defined."""
        )
    trees = tree["trees"]
    if not output_property:
        output_property = list(trees)[0]
    if output_property not in trees:

        raise CraftAiError(