class Node {
has $.parent;
has $.child;
has @.tests;
method AT-KEY(&code) {
@!tests.push: &code;
self
}
method add($child) {
without $!parent {
$!parent = $!child;
return self
}
self.new: :parent(self), :$child
}
}
sub term:<html> {
Node.new: :child<html>
}
multi infix:<< <- >>(Node $parent, $child) {
Node.new: :$parent, :$child
}
say (html <- "body" <- "h1"){ *.id eq "red" }