I think both ways should work.
It is much easier to handle the old node case, so I do it first.
I also have concerns that the discovery code for new node has indented 4 times, and it will be quite ugly if handle it first.