import std.exception;
// synchronized // Compiles without error when uncommented
class HierObject {
private shared HierObject _root;
private shared HierObject _parent;
shared(const(HierObject)) root() const {
if(_root) return _root;
else {
enforce(_parent,
"HierObject Instance does not have a parent!");
return this.parent().root();
}
}
shared(const(HierObject)) parent() const {
enforce(_parent);
return _parent;
}
}