Revert "Put leaf functions to the struct leaf, not namespace leaf."

This reverts commit bacfb129f300d14040c436ab0d52779e4145ddbf.