Implemented basic treeToInput