HDNode: move var declaration out of branches