def get_child_entity_from_path_by(field, children)
      # the next child in the path
      child_value = children.shift

      # get the child entity
      child = send(:children).find { |c| c.send(field) == child_value }

      # we have some recursion to do - we're not at the end of the array
      # so call this method again with a smaller set of children
      return child.get_child_entity_from_path_by(field, children) if child && !children.empty?

      child # this is the final thing in the array - return it
    end
def get_child_entity_from_path_by(field, children)
      # the next child in the path
      child_value = children.shift

      # get the child entity
      child = send(:children).find { |c| c.send(field) == child_value }

      # we have some recursion to do - we're not at the end of the array
      # so call this method again with a smaller set of children
      return child.get_child_entity_from_path_by(field, children) if child && !children.empty?

      child # this is the final thing in the array - return it
    end
Given a field and an array of child fields, we need to recurse through them to get the last one

 @param field [Symbol] the field we need to search for
 @param children [Array] an array of field values to match against
 @return an entity matching this class, which is the last in the tree