/;{^\;{Z[{Z0]z^[/@^\@^0]~`L`Ln[0`P]
Try it on the online Branch interpreter!
Of course, it's only natural that a language based on binary trees would have a way to solve this challenge. Branch is still in development; I'm not sure how I could've solved this before adding a bunch of bugfixes and a couple of new helpers.
Pretty-printing the tree was actually around from the start though. I used it as a debug feature; never thought I would've found a challenge so soon to use a debug feature as output formatting for :P
Explanation
The command line argument is automatically loaded into the first and only node in the binary tree. Note that [...] is the same as in BF; that is, it's a while loop, so if the current value is 0 at [, it skips to ], and if the current value is non-zero at ], it jumps back to [. Therefore, [...0] will only run if the value is non-zero, but then the value is zeroed at the end and so it never runs more than once. Essentially, this is an if statement.
/;{ Go to the left child, copy the parent, and decrement ^\;{ Go back to the parent, go to the right child, copy, and decrement Z Save the value to register Z [ 0] If that value is not zero {Z Decrement and save to Z (we need to save the value because it gets zeroed to allow the if statement to end) z Restore Z; this is (parent value - 2) if parent value is not 1, and otherwise just 0 ^ Go back to the parent [ 0] If the node is non-zero /@ Go to the left child and run this line on that, returning here when done ^\@ Go to the right sibling and run this line on that, returning here when done ^ Go to the parent, then zero it to end the if statement ~ Return to @, if we are currently in a sub-evaluation. If not, this gets skipped, and we can end the program `L Delete all leaves; every node with leaves is a 0 with -1 and -2 as children; these shouldn't be output `L Delete all leaves again; it might be valid to output such that these leaves are considered the "null" elements like my APL solution and the 2-byte jelly solution do, but I decided to remove them for style and this code is long enough as it is [ ] While this node is non-zero (input 0 and 1 give the same tree, so we need to suppress output if the value was 0) 0 Zero the top node; this turns the while loop into an if statement and also prevents the final output from having the value there `P Pretty-print the tree; this was created for debugging purposes, but conveniently enough, lets us answer this challenge quite nicely
[], and then the single-node graph becomes[[],[]]. Or you can wrap the entire graph in an Option type, etc. \$\endgroup\$