High level synthesis through folding of data flow graphs: optimal intra-node scheduling