docs: private void generateLegalTimesTree() {
          // Create a quick cache of numbers to their keycodes.
          int k0 = KeyEvent.KEYCODE_0;
          int k1 = KeyEvent.KEYCODE_1;
          int k2 = KeyEvent.KEYCODE_2;
          int k3 = KeyEvent.KEYCODE_3;
          int k4 = KeyEvent.KEYCODE_4;
          int k5 = KeyEvent.KEYCODE_5;
          int k6 = KeyEvent.KEYCODE_6;
          int k7 = KeyEvent.KEYCODE_7;
          int k8 = KeyEvent.KEYCODE_8;
          int k9 = KeyEvent.KEYCODE_9;
  
          // The root of the tree doesn't contain any numbers.
          mLegalTimesTree = new Node();
  
          // In case we're only allowing hours
          if (!mEnableMinutes && mIs24HourMode) {
              // The first digit may be 0-1
              Node firstDigit = new Node(k0, k1);
              mLegalTimesTree.addChild(firstDigit);
  
              // When the first digit is 0-1, the second digit may be 0-9
              Node secondDigit = new Node(k0, k1, k2, k3, k4, k5, k6, k7, k8, k9);
              firstDigit.addChild(secondDigit);
  
              // The first digit may be 2
              firstDigit = new Node(k2);
              mLegalTimesTree.addChild(firstDigit);
  
              // When the first digit is 2, the second digit may be 0-3
              secondDigit = new Node(k0, k1, k2, k3);
              firstDigit.addChild(secondDigit);
              return;
          }
          //noinspection ConstantConditions
          if (!mEnableMinutes && !mIs24HourMode) {
              // We'll need to use the AM/PM node a lot.
              // Set up AM and PM to respond to "a" and "p".
              Node ampm = new Node(getAmOrPmKeyCode(AM), getAmOrPmKeyCode(PM));
  
              // The first digit may be 1
              Node firstDigit = new Node(k1);
              mLegalTimesTree.addChild(firstDigit);
  
              // If the first digit is 1, the second one may be am/pm 1pm
              firstDigit.addChild(ampm);
              // If the first digit is 1, the second digit may be 0-2
              Node secondDigit = new Node(k0, k1, k2);
              firstDigit.addChild(secondDigit);
              secondDigit.addChild(ampm);
  
              // The first digit may be 2-9
              firstDigit = new Node(k2, k3, k4, k5, k6, k7, k8, k9);
              mLegalTimesTree.addChild(firstDigit);
              firstDigit.addChild(ampm);
              return;
          }
  
          // In case minutes are allowed
          if (mIs24HourMode) {
              // We'll be re-using these nodes, so we'll save them.
              Node minuteFirstDigit = new Node(k0, k1, k2, k3, k4, k5);
              Node minuteSecondDigit = new Node(k0, k1, k2, k3, k4, k5, k6, k7, k8, k9);
              // The first digit must be followed by the second digit.
              minuteFirstDigit.addChild(minuteSecondDigit);
  
              if (mEnableSeconds) {
                  Node secondsFirstDigit = new Node(k0, k1, k2, k3, k4, k5);
                  Node secondsSecondDigit = new Node(k0, k1, k2, k3, k4, k5, k6, k7, k8, k9);
                  secondsFirstDigit.addChild(secondsSecondDigit);
  
                  // Minutes can be followed by seconds.
                  minuteSecondDigit.addChild(secondsFirstDigit);
              }
  
              // The first digit may be 0-1.
              Node firstDigit = new Node(k0, k1);
              mLegalTimesTree.addChild(firstDigit);
  
              // When the first digit is 0-1, the second digit may be 0-5.
              Node secondDigit = new Node(k0, k1, k2, k3, k4, k5);
              firstDigit.addChild(secondDigit);
              // We may now be followed by the first minute digit. E.g. 00:09, 15:58.
              secondDigit.addChild(minuteFirstDigit);
  
              // When the first digit is 0-1, and the second digit is 0-5, the third digit may be 6-9.
              Node thirdDigit = new Node(k6, k7, k8, k9);
              // The time must now be finished. E.g. 0:55, 1:08.
              secondDigit.addChild(thirdDigit);
  
              // When the first digit is 0-1, the second digit may be 6-9.
              secondDigit = new Node(k6, k7, k8, k9);
              firstDigit.addChild(secondDigit);
              // We must now be followed by the first minute digit. E.g. 06:50, 18:20.
              secondDigit.addChild(minuteFirstDigit);
  
              // The first digit may be 2.
              firstDigit = new Node(k2);
              mLegalTimesTree.addChild(firstDigit);
  
              // When the first digit is 2, the second digit may be 0-3.
              secondDigit = new Node(k0, k1, k2, k3);
              firstDigit.addChild(secondDigit);
              // We must now be followed by the first minute digit. E.g. 20:50, 23:09.
              secondDigit.addChild(minuteFirstDigit);
  
              // When the first digit is 2, the second digit may be 4-5.
              secondDigit = new Node(k4, k5);
              firstDigit.addChild(secondDigit);
              // We must now be followd by the last minute digit. E.g. 2:40, 2:53.
              secondDigit.addChild(minuteSecondDigit);
  
              // The first digit may be 3-9.
              firstDigit = new Node(k3, k4, k5, k6, k7, k8, k9);
              mLegalTimesTree.addChild(firstDigit);
              // We must now be followed by the first minute digit. E.g. 3:57, 8:12.
              firstDigit.addChild(minuteFirstDigit);
          } else {
              // We'll need to use the AM/PM node a lot.
              // Set up AM and PM to respond to "a" and "p".
              Node ampm = new Node(getAmOrPmKeyCode(AM), getAmOrPmKeyCode(PM));
  
              // Seconds will be used a few times as well, if enabled.
              Node secondsFirstDigit = new Node(k0, k1, k2, k3, k4, k5);
              Node secondsSecondDigit = new Node(k0, k1, k2, k3, k4, k5, k6, k7, k8, k9);
              secondsSecondDigit.addChild(ampm);
              secondsFirstDigit.addChild(secondsSecondDigit);
  
              // The first hour digit may be 1.
              Node firstDigit = new Node(k1);
              mLegalTimesTree.addChild(firstDigit);
              // We'll allow quick input of on-the-hour times. E.g. 1pm.
              firstDigit.addChild(ampm);
  
              // When the first digit is 1, the second digit may be 0-2.
              Node secondDigit = new Node(k0, k1, k2);
              firstDigit.addChild(secondDigit);
              // Also for quick input of on-the-hour times. E.g. 10pm, 12am.
              secondDigit.addChild(ampm);
  
              // When the first digit is 1, and the second digit is 0-2, the third digit may be 0-5.
              Node thirdDigit = new Node(k0, k1, k2, k3, k4, k5);
              secondDigit.addChild(thirdDigit);
              // The time may be finished now. E.g. 1:02pm, 1:25am.
              thirdDigit.addChild(ampm);
  
              // When the first digit is 1, the second digit is 0-2, and the third digit is 0-5,
              // the fourth digit may be 0-9.
              Node fourthDigit = new Node(k0, k1, k2, k3, k4, k5, k6, k7, k8, k9);
              thirdDigit.addChild(fourthDigit);
              // The time must be finished now, when seconds are disabled. E.g. 10:49am, 12:40pm.
              fourthDigit.addChild(ampm);
  
              // When the first digit is 1, the second digit is 0-2, and the third digit is 0-5,
              // and fourth digit is 0-9, we may add seconds if enabled.
              if (mEnableSeconds) {
                  // The time must be finished now. E.g. 10:49:01am, 12:40:59pm.
                  fourthDigit.addChild(secondsFirstDigit);
              }
  
              // When the first digit is 1, and the second digit is 0-2, the third digit may be 6-9.
              thirdDigit = new Node(k6, k7, k8, k9);
              secondDigit.addChild(thirdDigit);
              // The time must be finished now. E.g. 1:08am, 1:26pm.
              thirdDigit.addChild(ampm);
  
              // When the first digit is 1, and the second digit is 0-2, and the third digit is 6-9,
              // we may add seconds is enabled.
              if (mEnableSeconds) {
                  // The time must be finished now. E.g. 1:08:01am, 1:26:59pm.
                  thirdDigit.addChild(secondsFirstDigit);
              }
  
              // When the first digit is 1, the second digit may be 3-5.
              secondDigit = new Node(k3, k4, k5);
              firstDigit.addChild(secondDigit);
  
              // When the first digit is 1, and the second digit is 3-5, the third digit may be 0-9.
              thirdDigit = new Node(k0, k1, k2, k3, k4, k5, k6, k7, k8, k9);
              secondDigit.addChild(thirdDigit);
              // The time must be finished now if seconds are disabled. E.g. 1:39am, 1:50pm.
              thirdDigit.addChild(ampm);
  
              // When the first digit is 1, and the second digit is 3-5, and the third digit is 0-9,
              // we may add seconds if enabled.
              if (mEnableSeconds) {
                  // The time must be finished now. E.g. 1:39:01am, 1:50:59pm.
                  thirdDigit.addChild(secondsFirstDigit);
              }
  
              // The hour digit may be 2-9.
              firstDigit = new Node(k2, k3, k4, k5, k6, k7, k8, k9);
              mLegalTimesTree.addChild(firstDigit);
              // We'll allow quick input of on-the-hour-times. E.g. 2am, 5pm.
              firstDigit.addChild(ampm);
  
              // When the first digit is 2-9, the second digit may be 0-5.
              secondDigit = new Node(k0, k1, k2, k3, k4, k5);
              firstDigit.addChild(secondDigit);
  
              // When the first digit is 2-9, and the second digit is 0-5, the third digit may be 0-9.
              thirdDigit = new Node(k0, k1, k2, k3, k4, k5, k6, k7, k8, k9);
              secondDigit.addChild(thirdDigit);
              // The time must be finished now. E.g. 2:57am, 9:30pm.
              thirdDigit.addChild(ampm);
  
              // When the first digit is 2-9, and the second digit is 0-5, and third digit is 0-9, we
              // may add seconds if enabled.
              if (mEnableSeconds) {
                  // The time must be finished now. E.g. 2:57:01am, 9:30:59pm.
                  thirdDigit.addChild(secondsFirstDigit);
              }
          }
      }