<commit_before>from __future__ import absolute_import
from __future__ import division
from __future__ import print_function


class TreeNode(object):
    """Tree node class collects helper functions for BinarySearchTree."""
    def __init__(self, key, value, 
                 left=None, right=None, parent=None):
        self.key = key
        self.value = value
        self.left_child = left
        self.right_child = right
        self.parent = parent

    def has_left_child(self):
        return self.left_child

    def has_right_child(self):
        return self.right_child

    def is_left_child(self):
        return self.parent and self.parent.left_child == self

    def is_right_child(self):
        return self.parent and self.parent.right_child == self

    # TODO: finish TreeNode class.

<commit_msg>Add is_root() and is_leaf()<commit_after>from __future__ import absolute_import
from __future__ import division
from __future__ import print_function


class TreeNode(object):
    """Tree node class collects helper functions for BinarySearchTree."""
    def __init__(self, key, value, 
                 left=None, right=None, parent=None):
        self.key = key
        self.value = value
        self.left_child = left
        self.right_child = right
        self.parent = parent

    def has_left_child(self):
        return self.left_child

    def has_right_child(self):
        return self.right_child

    def is_left_child(self):
        return self.parent and self.parent.left_child == self

    def is_right_child(self):
        return self.parent and self.parent.right_child == self

    def is_root(self):
        return not self.parent

    def is_leaf(self):
        return not (self.left_child or self.right_child)

    # TODO: finish TreeNode class.


{'fraction_non_alphanumeric': 0.0767077267637178, 'fraction_numerical': 0.0, 'mean_word_length': 2.778012684989429, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '84461', 'n_tokens_mistral': 518, 'n_tokens_neox': 496, 'n_words': 145}