Factor out branch and leaf nodes into node.h