category_tree.rb
def find_node(name)
    if self.name == name
      return self
    end

    # Check the left side
    unless self.left_child.nil?
      left_node = self.left_child.find_node(name)
    end

    if left_node.nil?
      # Check the right side
      unless self.right_child.nil?
        return self.right_child.find_node(name)
      end
    else
      return left_node
    end
  end
# Recursively finds the node (this parent or a child) that matches the passed name
Recursively finds the node (this parent or a child) that matches the passed name
Recursively finds the node ( this parent or a child ) that matches the passed name
def find_node(name)
    if self.name == name
      return self
    end
    unless self.left_child.nil?
      left_node = self.left_child.find_node(name)
    end
    if left_node.nil?
      unless self.right_child.nil?
        return self.right_child.find_node(name)
      end
    else
      return left_node
    end
  end
def find_node ( name ) if self . name == name return self end unless self . left_child . nil? left_node = self . left_child . find_node ( name ) end if left_node . nil? unless self . right_child . nil? return self . right_child . find_node ( name ) end else return left_node end end
Recursively finds the node (this parent or a child) that matches the passed name
Recursively finds the node ( this parent or a child ) that matches the passed name
# Check the left side # Check the right side
name