separate Node class to fix flatMap signature